-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Issue with Trailing Slashes in URLs Preventing Middleware Execution in Astro #12537
Comments
Hi. It's not totally clear to me what you mean when you say the middleware is not executed correctly. Is it not executed at all, or in the wrong way? If the latter, wrong in what way. Can you provide a reproduction that includes the source code, ideally via stackblitz. Thanks |
Hello @rajpatel2435. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
Hi @ascorbic Issue is that when I type in browser with multiple trailing slashes https://vegasaces.com/games/slots///////// in Astro logs terminal I just got how can I fix that so I only have one trailing slashes in the end of URL? https://github.com/rajpatel2435/Slotsparadise_Astro Thanks |
That's not something we can use as a minimal reproduction. Please create a minimal reproduction, ideally using astro.new and Stackblitz. |
Hi @ascorbic why in Astro terminal we are not getting URL with multiple trailing slash? Thanks |
That link shows a 404 page for me. Please see the instructions on creating a minimal reproduction. Please don't just share your whole site: you need to narrow it to the smallest example that reproduces the problem. It's usually best to start from a starter site rather than from your own site. |
Hi @ascorbic This is the minimal project structure https://stackblitz.com/~/github.com/rajpatel2435/slots?file=.env&initialPath=/how-to-play/// Thanks |
That project has no middleware, so I don't know how you can reproduce a bug. Can you please start from an empty project from https://astro.new/basics and add just the parts needed to demonstrate the bug. |
Hi @ematipico is there any update on this? Thanks |
Sorry @rajpatel2435 , but your reproduction isn't minimal, please provide one |
Solved from my side |
Hello @tordans @altano @madbook
Astro Info
If this issue only occurs in one browser, which browser is a problem?
All Browser
Describe the Bug
When accessing URLs with multiple trailing slashes, such as:
https://vegasaces.com/games/slots/lucky-dama-muerta//////////
The URL is automatically normalized in the backend to:
/games/slots/lucky-dama-muerta/
However, this normalization seems to bypass middleware logic. As a result, middleware doesn't execute as expected for the raw incoming URL.
Steps to Reproduce:
Create an Astro project with a middleware to log requests or process specific slugs.
Access a URL with multiple trailing slashes (e.g., //////////).
Observe that the middleware does not execute correctly for the normalized path.
What's the expected result?
Astro should identify and process URLs with multiple trailing slashes correctly, ensuring middleware functions execute as intended.
Current Behavior:
URLs with trailing slashes are normalized by Astro, but middleware logic does not handle the original raw URL, causing inconsistencies.
Link to Minimal Reproducible Example
https://vegasaces.com/games/slots/lucky-dama-muerta//////////
Participation
The text was updated successfully, but these errors were encountered: