vrtmrz / obsidian-livesync

MIT License
5.13k stars 167 forks source link

NGINX CORS wrong #503

Closed maskalix closed 1 month ago

maskalix commented 1 month ago

I'm using CouchDB on one machine (call it server, 192.168.0.50, opened port) and NGINX on other machine (gate, 192.168.0.100). I want to reverseproxy the CouchDB online, but still says:

Access to fetch at 'https://domain.tld/data/' from origin 'app://obsidian.md' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'.

I don't really understand the cause of this problem, as of i see the allow origin below (part of my NGINX site config)

     set $cors_origin "";
        if ($http_origin ~* "(app://obsidian.md|capacitor://localhost|http://localhost)") {
            set $cors_origin $http_origin;
        }

        add_header Access-Control-Allow-Origin $cors_origin always;
        add_header Access-Control-Allow-Methods "GET, PUT, POST, HEAD, DELETE" always;
        add_header Access-Control-Allow-Headers "accept, authorization, content-type, origin, referer" always;
        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Max-Age 3600;