-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: check if endpoint exists for dynamic pages when checking for red… #6994
Conversation
📊 Benchmark resultsComparing with 1ff368f
|
src/utils/proxy.ts
Outdated
proxyResHeaders = { | ||
...proxyResHeaders, | ||
'content-length': String(responseBody.byteLength), | ||
if (!proxyResHeaders['transfer-encoding']) { |
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.
@smnh you added this, but when there is transfer-encoding, you should not send content-length.
sindresorhus/got#1576
WDYT about this change?
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.
According to MDN, It looks like it should be ommitted only when Transfer-Encoding
is chunked
.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding#syntax
And it make sense, because for regular non chunked encodings like gzip and deflate you do want to have content-length.
if (proxyResHeaders['transfer-encoding']?.includes('chunked') {
...
}
5ef70f4
to
09a923c
Compare
09a923c
to
1688dd0
Compare
…irect
🎉 Thanks for submitting a pull request! 🎉
Summary
Fixes WRFL-2122
Basically we are checking only for static files when trying to determinate if we should do the
non forced
redirect.In dynamic SSG, when they either run in
dev mode
or having dynamic endpoints (not a static files), we are not detecting it and doing the redirect, which is wrong.I've added a simple checker via
fetch url, { method: HEAD }
- which checks if the endpoint exists.Example
Assume next
netlify.toml
:Run
netlify dev
.Make change to some code file.
Open
http://localhost:8888
. See that change is not applied. See in consoleProxying to https://www.netlify.app/
.Thats wrong, it should actually detect that there is an index route in current site and not proxy.
For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)