-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Ability to serve base page without trailing slash #9236
Comments
I don't think Vite needs a new option, it should just accept |
Yeah, I mentioned that option as well. It's a simpler user API, but likely to be a breaking change and harder for developers to use. I don't know which is better and am fine with either solution |
This was discussed at today's meeting. It was suggested to put together a PR for it. We also discussed the possibility of a helper method for handling appending a path to a base URL. We were trying to figure out how to help frameworks migrate and thought one possibility might be that the helper could be backported to 3.2 so that frameworks can start adopting the helper and when we disable enforcement of the trailing slash there will not be an effect on the frameworks that have already moved to using the helper. |
#10590 was merged in order to append the URL to the base path in a safe manner throughout the codebase regardless of whether it ends with a The first thing would be to change the config validation to not enforce a trailing vite/packages/vite/src/node/config.ts Line 815 in 675bf07
Possibly the base middleware would need some small tweaks https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/base.ts And we should add a test to ensure that a base URL with no trailing slash works as intended |
You missed the place where it says Nevertheless, I've opened a PR for this and I think the basic functionally is there already. Some behavior has to be decided on and maybe someone else can help me with the remaining broken tests. |
That's great! Thank you so much @BenediktAllendorf! I might not be able to look at this week, but will definitely try to help get it in before the first 4.0 alpha release. Thanks for finding the place I missed! (I searched for everywhere |
Co-authored-by: Ben McCann <[email protected]> Closes #9236 Closes #8770 Closes #8772
Co-authored-by: Ben McCann <[email protected]> Closes vitejs/vite#9236 Closes vitejs/vite#8770 Closes vitejs/vite#8772
Co-authored-by: Ben McCann <[email protected]> Closes vitejs/vite#9236 Closes vitejs/vite#8770 Closes vitejs/vite#8772
Description
SvelteKit has a
trailingSlash
option which indicates whether we expect URLs to have a trailing slash or not. By default all URLs do not have a trailing slash. However, Vite forces a trailing slash on the base URL.Implementing this would close #8770 and #8772
Suggested solution
Vite could accept
base
with or without a trailing slash so that the user can decide which they would prefer. However, this would be a breaking change as anything readingbase
from the config would now have to handle the possibility both of it having or not having a trailing slashAlternative
Add a new
trailingSlash
option similar to SvelteKit's. I think it would likely only affect the base URL though for Vite#8772 is open which affects this functionality as well, but would not work as a solution for SvelteKit as it always forces a trailing slash and would conflict with SvelteKit's
trailingSlash
optionAdditional context
SvelteKit historically hasn't used the
publicDir
andbase
options, but does its own static asset serving. I put together a branch to use Vite's implementation, but some of our tests are failing with it due to this issue, which is a blocker for us.https://github.com/sveltejs/kit/pull/5601/files#r923967104
Validations
The text was updated successfully, but these errors were encountered: