Welcome! Log In Create A New Profile

Advanced

How do I add Access-Control-Allow-Origin in NGINX?

Posted by Erica9595 
How do I add Access-Control-Allow-Origin in NGINX?
June 08, 2023 05:02AM
Hi all as the title says I can't figure out how to set the ""Access-Control-Allow-Origin"" directive in the conf file. In fact, when I try to access from the front end, the back end fails to authenticate me and I always get this error which refers to the directive specified above:
""Http failure response for site_name_example/login: 0 Unknown Error""

My configuration is as follows:


server {
server_name site_name_example;

location / {

proxy_set_header X-Forwarded-Host $server_name;
proxy_pass http://x.x.x.x:4200;

}



location /api {
proxy_pass http://y.y.y.y:9090/example;
add_header Access-Control-Allow-Origin *;
}


}

I hope someone help me
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 89
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready