Hi, How to solve the access control allow origin?

I host two site in my server

* https://mydomain.com {
*       root /var/www/html
*      gzip
* }

* https://api.mydomain.com {
*     proxy /  http://NODE_IP:3001
* }

Then “mydomain .com” will talk to “api.mydomain .com” for resources, but it got “access control allow origin” error, I try two way to solve this, but it didn’t work.
one is use “header /api Access-Control-Allow-Origin *”

```
https://api.mydomain.com {
    header /api Access-Control-Allow-Origin *
    proxy /  http://NODE_IP:3001
 }'

two :

https://api.mydomain.com {
       cors
       proxy /  http://NODE_IP:3001
}

or something like this:
cors / { origin http://allowedSite.com origin http://anotherSite.org https://anotherSite.org methods POST,PUT allow_credentials false max_age 3600 allowed_headers X-Custom-Header,X-Foobar exposed_headers X-Something-Special,SomethingElse }
Can someone help me to solve this? Thank you very much! :neutral_face:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.