-
Notifications
You must be signed in to change notification settings - Fork 126
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
TrailingSlash using rewrite for a fetch call results on infinite loop #279
Comments
Hi thanks for the investigation and fix, can you put up a PR and add some test cases around this? |
Ey @khuezy yeah I'm on it. I'll update here when ready. |
AlbertSabate
added a commit
to AlbertSabate/open-next
that referenced
this issue
Oct 13, 2023
PR ready for review: #280 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello team,
I was struggling with an infinite loop and blaming the cache on CloudFront. However, after some hours of research, the issue is with the trailing slash.
Explanation step by step:
My investigation arrived here. I'm still researching why this creates an infinite loop because, from my understanding, it should double redirect to not trailing slash and then to the final API URL.
In localhost, the setup is working correctly.
To give it a shot, it will be as easy as installing mixpanel-browser and initialise with a rewrite, for example:
I tried enabling trailing slash, and then it worked as expected.
However, when using search parameters, something seems off.
Result when accessing to:
-> https://xxxx.cloudfront.net/mp/track?verbose=1&ip=1&_=1697202041851
<- https://xxxx.cloudfront.net/mp/track?verbose=1&ip=1&_=1697202041851///////////////////////////////////////////////////////////////////////////////////////////////
(Notice the loop)
Expectation:
UPDATE
I found something more.
On the file [Line: 176 && 191]: https://github.com/sst/open-next/blob/main/packages/open-next/src/adapters/routing/matcher.ts
If the URL contains search parameters, then that is when the infinite loop happens. I think considering search params on this redirect will fix the issue.
SOLUTION
On the file [Line: 176 && 191]: https://github.com/sst/open-next/blob/main/packages/open-next/src/adapters/routing/matcher.ts
The text was updated successfully, but these errors were encountered: