• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

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