Redirect doesn't invoke mounted hook from nuxt app

Hi, I’m trying todo a rewrite to get a param from the url www.myapp/test/PARAM

So I tried this redirect.

  from = "/test/*"
  to = "/test"
  status = 200

I’m using nuxtjs to build my app. Inside my mounted hook I want to get the route

    <h1>TEST PAGE</h1>
export default {
  mounted() {

If I use this url www.myapp/test/ I see an output in the console, but if I’m using www.myapp/test/PARAM the console is empty… but the content of the page is displayed

this is the folder structure

-| test/
---| index.vue

Is this the proper way to get params from dynamic urls and if yes what I’m doing wrong?


Hey there,
If I’m understanding correctly, the param won’t be available at the time you’re trying to access it because of your redirect rule. That rule is processed before we return the page to the browser, so any param you enter will have been parsed out by the time you are checking the console.log. The timing of this is:

  1. You enter in the browser url bar
  2. The browser makes a request to our servers
  3. Our servers check the redirect rule associated with that path. The rule says “if someone requests*, send them to this path instead:
  4. Our servers return to the browser; your browser updates accordingly.

So if you want to retain the param, I’d suggest incorporating query params into your redirect rules:

Let us know if that helps or if you have other questions!