-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Router trailing slash not behaving as expected. #8350
Comments
I also see this issue, it happens on production when running the generate for static. |
same |
This should be fixed in v2.14.8. Please reopen if not. |
Hi I was experiencing the same issue. I updated to 2.14.8 as @pi0 suggests. This fixes the issue, but creates another. How do I remove trailing slashes from server side? |
@madsh93 If it's a static/generated site, then it is not a Nuxt issue and you should look into your server or web host's settings. (If it's Note there is a related issue with |
@danielroe yes, the error indeed is when using nuxt start. I can also replicate this error also on a relatively new project without many dependencies. |
@danielroe after further investigation my hydration error was caused by removing components: { I thought it was related, because adding trailing slash fixed it - which is then related to the nuxt start error I believe. |
Hey I updated to 2.15.7 and when generating static in production Nuxt still adds the trailing slash, even with trailingSlash: false! When running in development the trailingSlash: false is respected and behavior consistent with: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-router#trailingslash Any ideas? |
@joaolcorreia did you manage to fix this? bumping into the same issue |
@pjatx same problem here + in my case this breaks nuxt content hence users get 404 after refresh. |
@aabele I ended up just moving to trailing slashes in the router and sitemap configs to keep the project moving ¯_(ツ)_/¯ |
@pjatx I was thinking a url without a trailing slash is a file and with trailing is a directory. I ended up using a trailing slash on everything and solved the problem. I wasn't wrapping my head around this properly I guess. |
@joaolcorreia yeah, it's more of stylistic concern these days with modern frameworks. Browsers will serve whatever index.html file is in the directory unless you specify something else. |
@joaolcorreia I figured it out. You should set |
Bump. Having the same issue on version 2.15.8. I don't undersand why it was closed with no solution. |
Any update? |
If you are encountering this issue, please try with |
this works for me:
|
As mentioned above by others, adding this to nuxt.config.js (nuxt 2.15.8) worked in my case as well.
|
Versions
Reproduction
Code:
https://codesandbox.io/s/nuxt-glitches-eb37j
Preview:
https://csb-eb37j.netlify.app/
Steps to reproduce
What is Expected?
There should never be a slash at the end of the URL.
In the
nuxt.config.js
file we have specified:What is actually happening?
A 301 redirect is occurring and placing a slash at the end.
This is not unique to Netlify as it also happens locally when running
npm run generate
followed bynpm run start
. Note that this does NOT occur when runningnpm run dev
. It seems to only be in a production build.The docs state that this should not be the case if setting the value to
false
and notundefined
.https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-router#trailingslash
Tested in full static mode using
target: 'static'
The text was updated successfully, but these errors were encountered: