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

Add Access-Control-Expose-Headers in --cors mode #814

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

Conversation

jtbandes
Copy link

@jtbandes jtbandes commented Oct 22, 2024

By default, browsers only allow clients to read CORS-safelisted response headers. However, sometimes it is useful to read other headers that are not safelisted by default, such as Accept-Ranges. The Access-Control-Expose-Headers header allows controlling which headers are exposed to the client.

This change exposes all headers (*) when --cors is used.

It could be useful to allow more fine-grained configuration of exposed headers, however, it seems that the existing --cors mode is a very coarse toggle so I just used * for consistency.

I didn't see a relevant place to update docs – is this tool missing documentation for the CLI flags?

By default, browsers only allow clients to read "CORS-safelisted response headers": https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_response_header

However, sometimes it is useful to read other headers that are not safelisted by default, such as `Accept-Ranges`. The `Access-Control-Expose-Headers` header allows controlling which headers are exposed to the client. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers

This change exposes all headers when `--cors` is used.
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