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

Proposal: Dynamic Access-Control-Expose-Headers Support #29

Open
yinheli opened this issue Sep 11, 2024 · 0 comments
Open

Proposal: Dynamic Access-Control-Expose-Headers Support #29

yinheli opened this issue Sep 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@yinheli
Copy link

yinheli commented Sep 11, 2024

Summary

This proposal aims to enhance the php-cors library by adding support for dynamic of the Access-Control-Expose-Headers header. Currently, this header is set globally, which limits flexibility in scenarios where different routes require different exposed headers.

Motivation

In complex applications, different routes often need to expose different custom headers. The current static, global configuration of Access-Control-Expose-Headers in php-cors doesn't provide the necessary flexibility for such cases. This proposal seeks to address this limitation by allowing developers to dynamically set exposed headers at the controller or middleware level.

Proposed Implementation

  1. Modify the CORS middleware to check for an Access-Control-Expose-Headers header in the response object.
  2. If present, merge this dynamically set header with the globally configured exposed headers.
  3. Use the combined list when setting the final Access-Control-Expose-Headers header in the CORS response.
yinheli added a commit to yinheli/php-cors that referenced this issue Sep 11, 2024
- Update CorsService to merge existing exposed headers with configured
- Add deduplication for exposed headers

fruitcake#29
@barryvdh barryvdh added the enhancement New feature or request label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants