1

Using Nuxt, we need to be able to render pseudo-routes, like this:

https://server.com/non-existent-route

Where "non-existent-route" is a dynamic path.

Normally, this would render error.vue. This is fine, as we've subverting the use of this page to render what we want. But... we just discovered that Nuxt is sending a 404 anyway! This only happens when the page is first loaded in a fresh tab, for some reason. This is very bad.

So, we need a way to avoid HTTP status 404 in some cases.

We found this: https://medium.com/finn-no/hacking-nuxts-404-logic-for-maximum-awesome-and-easy-proxying-e4efaeb03d66 which is actually not as helpful as we had hoped it would be, as it simply provides a way to proxy another URL, sending us back to the same problem.

We suspect there might be some middleware solution to this problem... but have not been able to come up with it.

2
  • why don't you use the normal dynamic routes? For me it is not understandable why the error is manipulated for this. Can you explain in more detail what you are up to or what the goal is? Commented Apr 3, 2020 at 13:23
  • dynamic routes were the first thing we thought of, too, but sadly this is not a solution. we want URLs to have the form described above (server.com/non-existent-route), and all these need to be rendered by the same page component. Commented Apr 3, 2020 at 17:13

1 Answer 1

-2

Turns out the answer was right here all long: https://nuxtjs.org/guide/routing#dynamic-nested-routes Rather disappointing that nobody suggested this extremely simple solution.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.