-
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 #280
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
return { | ||
type: event.type, | ||
statusCode: 308, | ||
headers: { | ||
Location: event.url.replace(/\/$/, ""), | ||
Location: `${headersLocation[0].replace(/\/$/, "")}${headersLocation[1] ? `?${headersLocation[1]}` : ''}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the internalEvent.url in the final return below also split the ?
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I code-reviewed that part, and it is already handled by handleRewrites fn.
On handleRewrite, we are doing it like this:
const urlQueryString = new URLSearchParams(convertQuery(query)).toString();
const queryString = urlQueryString ? `?${urlQueryString}` : "";
let rewrittenUrl = rawPath;
url: `${rewrittenUrl}${queryString}`,
This should be working as expected because we do not add or remove any slash. On my changes, I've gone for split('?') because there are fewer lines of code. But happy to match the style. I'm not sure if there are some code style guidelines somewhere :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fine, doesn't have to match style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Fixed eslint. |
Fixes: #279