-
Notifications
You must be signed in to change notification settings - Fork 693
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
Default trailingSlash config breaks relative links #628
Comments
Just wanted to confirm that I've run into similar. Looks like Short of broken user-supplied rewrite rules, it's very incorrect for correctly-supplied paths in an HTML to 404, and it's frustrating that this breakage is caused by gold plating. AFAICT, it's conventional for web servers to add a trailing slash when removing "index.html" from a URL (which keeps relative links within subpaths intact) but not to do the other things Thank you to @lukengda for explaining & providing a workaround... I thought I was going crazy, and even switched a static-page project to all absolute paths because I didn't realize the problem was |
Ok, apparently this issue has already been raised a few other times, over a period of years. A couple others:
But what I did as a workaround (because I still prefer serve to simplehttpserver): Create a {
"trailingSlash": true
} Then I put that in my home folder, and aliased Edit: the right Here's a better workaround:
|
I'm encountering the same issue. I have a directory like:
The |
still an issue two years later. i think adding a CLI option for trailing slashes would be a good idea to mitigate this as well. |
Relative href attributes are not correctly resolved based on the configuration of
cleanUrls
andtrailingSlash
config.Scenario
Files:
/login/index.html
/login/login.ts.html
The index.html has an anchor tag linking to the other page like following:
(Something like this could be found in an instanbul coverage html report)
This looks to me like a correct link that should correctly link from index.html to login.ts.html.
Observed behavior
serve
Location | /login/index
(this must be the result of thecleanUrls
setting removing the file ending .html)Location | /login
(is this also part of thecleanUrls
setting? but anyway, settingtrailingSlash
to false changes the target/login/
)Expected behavior
Serve should (by default) be configured, so that requesting localhost:5000/login/index.html should settle on one of the following URLs to not break relative URL resolution:
I am aware that i can configure my
serve.json
to disabletrailingSlash
. This solves my problem locally but i am arguing for making sure that the default configuration should be changed.The text was updated successfully, but these errors were encountered: