how to write global router-function in nuxt.js : <p>I am using Vue.js with Nuxt.js, but I got a problem in router's functions.</p>

<p>In the pure Vue, i can write in <code>main.js</code> like this:</p>

<pre><code>val route = new Router({
   routes:{
      [...]
   }
})

route.beforeEach(to,from,next){
    //do something to validate
}
</code></pre>

<p>And how to do the same in nuxt.js ? I can not find any file like <code>main.js</code>.</p>

<p>Also, all i know is to deal with the <code>pages</code> folder to achieve router, I can not set the redirect path</p>

<p>please help, thx :)</p>
