Skip to content

fix(api): resolve header overwriting and delimiter issue in Access-Control-Expose-Headers#4960

Merged
istae merged 5 commits intomasterfrom
fix/cors-expose-headers
Feb 3, 2025
Merged

fix(api): resolve header overwriting and delimiter issue in Access-Control-Expose-Headers#4960
istae merged 5 commits intomasterfrom
fix/cors-expose-headers

Conversation

@gacevicljubisa
Copy link
Member

@gacevicljubisa gacevicljubisa commented Jan 24, 2025

…response header

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

  • Replaced w.Header().Set with w.Header().Add to append headers rather than overwrite them.
  • Corrected delimiter for Access-Control-Expose-Headers from ; to , as per MDN documentation.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

  • Browser behavior: The semicolon delimiter (;) was causing issues, particularly in Chromium-based browsers. This was corrected by switching to a comma (,) delimiter for separating multiple header values.
  • Header overwriting: The use of w.Header().Set was causing overwriting of Access-Control-Expose-Headers. Replacing it with w.Header().Add ensures headers are appended, resolving inconsistencies in the response headers.

Related Issue (Optional)

[2.4.0] Access-Control-Expose-Headers is overridden, breaking browser Swarm apps #4959

Screenshots (if appropriate):

@Cafe137
Copy link

Cafe137 commented Jan 27, 2025

Would it be possible to add tests that check that headers are added instead of being replaced, to avoid a future regression?

@gacevicljubisa
Copy link
Member Author

Would it be possible to add tests that check that headers are added instead of being replaced, to avoid a future regression?

Yes, sure.

@istae istae marked this pull request as ready for review January 29, 2025 19:35
@istae istae requested review from acha-bill and istae as code owners January 29, 2025 19:35
@istae istae requested a review from janos January 29, 2025 19:35
@gacevicljubisa gacevicljubisa requested a review from janos January 30, 2025 14:25
Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for addressing my comments.

@istae istae merged commit c70cbfb into master Feb 3, 2025
15 checks passed
@istae istae deleted the fix/cors-expose-headers branch February 3, 2025 11:51
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.

[2.4.0] Access-Control-Expose-Headers is overridden, breaking browser Swarm apps

4 participants