• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Unable to change CORS header

JDev17

New Pleskian
Hi

Setting the CORS header is a major headache. Most of the time, nothing happens, two headers will be applied or the wrong header will be applied.

I have set a CORS header for nginx (example.com and example2.com for privacy reasons):

add_header 'Access-Control-Allow-Origin' 'https://example.com';

Then I moved / renamed my domain from example.com to example2.com and had to change the header again:

add_header 'Access-Control-Allow-Origin' 'https://example2.com';

After changing the header, nothing changed at all.
I get an error that the header is set to example.com but my domain is example2.com.

I have struggled a lot getting CORS to work before. Even setting the example.com header took me like 1h with server reboots, setting the header and removing it, setting apache headers and removing them, restarting the nginx service and much more until it suddenly worked.

I don't know if this is relevant but I am setting the header for a subdomain of example.com / example2.com

Any Idea what's causing this or am I doing something wrong?
 
Nevermind, I had set a header in my nodejs app which was passed on and I forgot to change it. I didn't know headers from a nodejs app will be passed on.
 
Back
Top