• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question Enable CORS for dockerized node.js api

Balduraan

New Pleskian
Hello there!

I have an ubuntu server with plesk obsidian 18.x running.
I have an dockerized node.js graphql api up and running. The api request are comming from an angular pwa and
I get an error that access was blocked due to cors policy.

I enabled CORS inside node.js of course, but I have no clue how to allow / configure CORS in plesk for a docker container.
Plesk is proxying requests from api.domain.com to the said container.

I hope someone can help me solving this problem. This is killing my development progress.

Edit: In plesk under "Settings for Apache & Nginx for api.domain.com" I added additional nginx-instructions: add_header 'Access-Control-Allow-Origin' '*';
And the error message changes to:
Code:
Access to fetch at 'https://api.domain.com/graphql' from origin 'https://app.domain.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
 
Last edited:
Back
Top