Skip to content

fix(middleware): avoid duplicate CORS headers behind proxies#2983

Open
leno23 wants to merge 1 commit into
labstack:v4from
leno23:fix/cors-no-duplicate-proxy-headers
Open

fix(middleware): avoid duplicate CORS headers behind proxies#2983
leno23 wants to merge 1 commit into
labstack:v4from
leno23:fix/cors-no-duplicate-proxy-headers

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

Test plan

  • go test ./middleware/...
  • TestCORSNoDuplicateHeadersFromUpstream — proxy layer + upstream both use CORS middleware, response has single Access-Control-Allow-Origin and Vary

Fixes #2853

Set CORS response headers after the handler runs for simple requests
and skip them when an upstream handler already set Access-Control-Allow-Origin.
This prevents duplicated headers when CORS middleware is used together
with reverse proxies in chained services.

Fixes labstack#2853

Co-authored-by: Cursor <cursoragent@cursor.com>
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