Skip to content
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

Invalid Access-Control-Request-Methods and Access-Control-Request-Headers HTTP headers #1250

Open
ehmicky opened this issue Oct 18, 2024 · 0 comments
Labels

Comments

@ehmicky
Copy link

ehmicky commented Oct 18, 2024

Describe the bug
@middy/http-cors sets the following HTTP response headers: Access-Control-Request-Methods and Access-Control-Request-Headers.

if (
options.requestHeaders &&
!existingHeaders.includes('Access-Control-Request-Headers')
) {
headers['Access-Control-Request-Headers'] = options.requestHeaders
}
if (
options.requestMethods &&
!existingHeaders.includes('Access-Control-Request-Methods')
) {
headers['Access-Control-Request-Methods'] = options.requestMethods
}

However, the correct spelling of the former header is Access-Control-Request-Method (no s).

Additionally, those headers are meant to be set by the client (in the request), not the server (in the response). See MDN and the standard.

This is in contrast with Access-Control-Allow-Methods and Access-Control-Allow-Headers, which are correctly set.

Expected behaviour
This seems to indicate those two headers should not be set at all, removing the requestMethods and requestHeaders options.

Additional context
Note: Express CORS middleware does not set those headers either.

@ehmicky ehmicky added the bug label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant