• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

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