-
-
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
HTTP HEAD request returns 403 #13079
Comments
We first encountered this with Astro v5 on 2 projects using Astro. Note: The bug does not surface when you do a When bisecting in the loculus-project/loculus codebase, astro v4.16.17 was still working fine and v5.0.2 was bad. Specific versions that made it bad:
|
I can reproduce within the astro code base using
Bisecting yields the following as the first bad commit: #12588 |
I believe this is the line of code that is causing the issue const sameOrigin =
(request.method === 'POST' ||
request.method === 'PUT' ||
request.method === 'PATCH' ||
request.method === 'DELETE') &&
request.headers.get('origin') === url.origin; request.method === 'HEAD' should be added to this list |
Actually, I was wrong. This fixes it, which is the line above what I pasted mentioned. if (request.method === 'GET' || request.method === "HEAD") {
return next();
} I submitted a pull request here #13100 with the fix |
Good spot @joshmkennedy! The bug was introduced in 315c5f3#diff-aeb15293e9b48a0df451f282702d3145060faecc40e2360faf3d9b059c862f1f where forbidden methods (POST, PATCH, DELETE,...) were wrongly inverted to just GET (omitting HEAD) |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using SSR and the standalone server in node, a HEAD request will return a 403 response.
What's the expected result?
A 200 response.
Link to Minimal Reproducible Example
https://github.com/fhennig/astro-head-403
Participation
In addition to the linked example, you can reproduce with the following steps:
npm create astro@latest
npm i @astrojs/node
npm run build
node ./dist/server/entry.mjs
curl --head http://localhost:4321
We noticed this because some uptime checkers do HEAD requests and showed our site as being down.
The text was updated successfully, but these errors were encountered: