Skip to content

Did you know?

Behind a reverse proxy, Apache's "Header always set" adds a second CORS header instead of replacing the backend's.

Use Header unset before Header always set when proxying an app that sends its own CORS headers.

Explained

Apache keeps headers set with always in a separate list from the headers that come back from a proxied application. So if your app already sends Access-Control-Allow-Origin and Apache adds it with Header always set, the browser gets it twice and fails with “The ‘Access-Control-Allow-Origin’ header contains multiple values”. We reproduced this on Apache 2.4.66.

Remove the backend’s copy first:

Header unset Access-Control-Allow-Origin
Header always set Access-Control-Allow-Origin "https://app.example.com"

Plain Header set does replace the backend’s value, but it skips error responses, so the unset-then-always pattern is the safer fix. Even better, set CORS in only one place: the app or Apache.

Learn more

← All tech tips · Suggest a fix

Back to top