-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does it work with build/generate? #1
Comments
This is my project's repository (open source at GitLab): Here it's the deploy at Netlify (the website is in Portuguese, but I think that the content is not relevant for the problem):
The module is configured in the nuxt.config.js with the following line:
|
Hey @renatocf! Unfortunately, the Will add this to the README asap! Maybe we could leverage the |
Though I'm not sure if vue-router will help when using |
Remove [nuxt-redirect module][1] given that it does not work in SPA or static mode (as discussed in the module's repository [issue #1][2]). Use Nuxt's redirect command in the index.vue page to redirect it to the current hackathon's page (as recommended by nuxt's repository [issue #1843][3]). [1]: https://github.com/nuxt-community/redirect-module [2]: nuxt-community/redirect-module#1 [3]: nuxt/nuxt#1843 Signed-off-by: Renato Cordeiro Ferreira <renato.cferreira@hotmail.com>
@manniL, after some time I found [this issue](I ended up following this issue: nuxt/nuxt#1843) from Nuxt's main repository that helped me solve my case. I used the |
@manniL for universal NuxtJS apps, setting up Netlify redirect doesn't work since it is kind of an SPA. So the only redirect that works is /* to /index.html 200. If you write any other redirects before this, such as /events/* to /events 301, navigating to a non-existent page /events/abc will bring up the Netlify error page (instead of NuxtJS error page). So the next solution I tried was this redirect-module but because I use Nuxt generate, the middleware provided by the module didn't work as mentioned. However, there is a way to get redirect working on NuxtJS with a SSR site (Nuxt generate). See my solution below:
What this does is simple, if Nuxt determines that the route path is not found, instead of showing the error page, we check the route path in layout(context) method and redirect all the dead links accordingly there. Finally, we return 'layout' or any other layout files you have to display your error message if none of the route path matches. One problem with this solution is that it's not done before loading the page, so the page may load path '/' first (because of Netlify redirect), before redirecting to the correct page determined in layout(context) found in error.vue. I'm using this specific solution because I re-developed a website in NuxtJS and I wasn't keeping to the old route paths. Moreover, some old links were used in media and other websites so it wouldn't be nice to show an error page saying the page doesn't exist. But since I'm using Nuxt generate, I'm willing to live with this solution for now until there is something better. Hope this helps someone out there! |
Hi,
First of all, thanks for this great module. It really simplified the task of redirecting routes with Nuxt!
I'm just having a little problem with it: I generated a static page with
nuxt generate
and deployed it to Netlify. I tried to redirect the base route/
to another route/something
, but it didn't work. I receive a "page not found" from Netlify. I also tried to make a production SPA withnuxt build
but the same happens. In development mode, however, everything works fines. Does the library handles the SPA / static mode or does it rely on Nuxt's universal mode (with a server) to run?Thanks for your help!
The text was updated successfully, but these errors were encountered: