Inconsistent URL trailing slash behavior between dev and preview servers
See original GitHub issueDescribe the bug
Multi-page apps created with Vite do not behave consistently between dev and build preview when visiting nested URLs that do not have a trailing slash.
Using the following folder structure:
├── package.json
├── vite.config.js
├── index.html
└── nested
└── index.html
Expected: Both dev and build servers have consistent behavior when visiting <root>/nested
Actual: Dev server shows index.html
from root when visiting <root>/nested
; must use <root>/nested/
instead. Build preview, however, shows nested/index.html
when visiting <root>/nested
.
Reproduction
https://github.com/noahmpauls/vite-bug-multipage-url
System Info
System:
OS: Windows 10 10.0.19043
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Memory: 1.02 GB / 7.75 GB
Binaries:
Node: 14.15.5 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
npmPackages:
vite: ^2.7.2 => 2.7.13
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Should You Have a Trailing Slash at the End of URLs? - Ahrefs
A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. But should you...
Read more >Fixing the trailing slash in Static Site Generation
The default behavior of different hosts is to add a trailing slash to serve that static file. Can we fix that?
Read more >Duplicate content and no default Next JS redirect from trailing ...
I have deployed next.js 11.1.0 test site and noticed that the redirect from trailing slash is not functional. Both URLs load creating duplicate...
Read more >Host and deploy ASP.NET Core Blazor WebAssembly
When deploying to an IIS server, you can use the URL Rewrite Module ... to href of the <base> tag, don't include a...
Read more >Resolving Django URLs with many trailing slashes
That looks like it's nginx-related. Somehow your web server is removing the trailing multiple slashes before proxy-passing to your app server.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’ve hit this inconsistency moving from Create React App/Craco to Vite.
We used to have
/foo
but to try and make production and development closer we’re going to have to change all our production urls to/foo/
to match development.Seems an annoying rule?
Was trying to work this out locally and wrote a plugin that seems to fix it:
https://gist.github.com/emma-k-alexandra/47ef18239e8a1e517160aff591e8132d
Example config: