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

fix(cors): avoid setting Access-Control-Allow-Origin if there is no matching origin #3510

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

uki00a
Copy link

@uki00a uki00a commented Oct 12, 2024

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Even if the Origin header of a request does not match a origin specified by origin option, CORS middleware always sets Access-Control-Allow-Origin header. I don't see this as a serious problem, but in some cases it may unintentionally expose a server setting.

References

@uki00a uki00a marked this pull request as ready for review October 12, 2024 10:55
@uki00a uki00a marked this pull request as draft October 12, 2024 11:13
@uki00a uki00a force-pushed the avoid-expose-first-allowed-origin branch from 3c54a7c to 5bf6c62 Compare October 12, 2024 11:32
@uki00a uki00a changed the title fix(cors): avoid exposing the first allowed origin fix(cors): avoid setting Access-Control-Allow-Origin if there is no matching origin Oct 12, 2024
@@ -34,6 +34,12 @@ describe('CORS by Middleware', () => {

app.use('/api5/*', cors())

Copy link
Author

@uki00a uki00a Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally added in #1129, but seems to have been lost at some point 👀

@uki00a uki00a marked this pull request as ready for review October 12, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant