HttpFileService could provide more options related to trailing slash
See original GitHub issueI was trying to clean up code using the new file service capabilities (removing hacky path mapping to redirect everything to index.html for example) but found I can’t remove all my hacks since we use “clean URLs” without a trailing slash to read index.html for that page. The current HttpFileService
will read index.html for requests that end with /
but not otherwise. Adding an option to HttpFileServiceBuilder that allows URLs without an extension to have slash added before resolving the file would make this simpler.
For reference, firebase’s related setting https://firebase.google.com/docs/hosting/full-config#control_trailing_slashes
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Nextjs should have more options for trailing slash. #23988
js will redirect urls with trailing slashes to their counterpart without a trailing slash. Can I disable it? Or can it be used...
Read more >Trailing slash in Flask route - python - Stack Overflow
But I'm wondering if there's a better solution, like a drop-in app configuration of some sort, similar to strict_slashes=False that I can apply ......
Read more >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 >To slash or not to slash | Google Search Central Blog
Historically, it's common for URLs with a trailing slash to indicate a directory, and those without a trailing slash to denote a file:....
Read more >What is a trailing slash? - Ryte Wiki
A trailing slash is the forward slash placed at the end of a URL. ... This multiple indexing can negatively effect the website...
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
Thanks for checking the behavior! It sounds like they follow armeria’s current behavior then. I guess I’ll add a flag, and it’s basically similar to doing this sort of config in nginx when needing slash-less URLs - https://stackoverflow.com/a/31189870
nginx and Apache HTTPd at least seem to send a redirect response when a client sent a request to a directory without a trailing slash (empty-to-slash), which matches the current
HttpServerHandler
behavior. I guess this kind of redirection is common for directories.However, they indeed don’t send a redirect when showing an index file. That being said, I guess we can:
HttpServerHandler
behavior as-isHttpFileService
redirect for empty-to-slash cases while serving an index file without redirectionAdditionally, we might want to add some configuration property to
Server
, likeTrailingSlashPolicy
if we need more flexibility?