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(middleware/cors): explicitly return No Content for the statusText when handling an OPTIONS request #3719

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

shawncarr
Copy link
Contributor

When the cors middleware processes an OPTIONS request by default, it returns the response status text from the context, c.res.statusText. However, in most cases, the middleware is executed before any routes or other middlewares that could modify the response statusText, leading to a Not Found response status. To align with the explicit 204 being returned, the response should also include No Content, similar to how the etag middleware handles setting the statusText to Not Modified.

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

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.70%. Comparing base (80c7e22) to head (e0c9f4e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3719   +/-   ##
=======================================
  Coverage   91.70%   91.70%           
=======================================
  Files         159      159           
  Lines       10165    10165           
  Branches     2919     2880   -39     
=======================================
  Hits         9322     9322           
  Misses        842      842           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yusukebe
Copy link
Member

yusukebe commented Dec 4, 2024

Hi @shawncarr

Thank you for the PR. I think this is good.

@usualoma Can you review this?

@usualoma
Copy link
Member

usualoma commented Dec 4, 2024

Hi @shawncarr, thank you.
LGTM!

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

yusukebe commented Dec 4, 2024

@shawncarr @usualoma Thanks!

Merging now.

@yusukebe yusukebe merged commit fc8fb0f into honojs:main Dec 4, 2024
16 checks passed
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.

3 participants