Question

Configuring CORS on App platform - Express

Hey All,

I have a pretty simple Express app running at https://hammerhead-app-ruqkl.ondigitalocean.app/. I have used the DigitalOcean settings for the app to configure a CORS policy as follows:

.* using Regex

ACCESS-CONTROL-ALLOW-METHODS GET, POST, CONNECT

ACCESS-CONTROL-ALLOW-HEADERS None

ACCESS-CONTROL-EXPOSE-HEADERS None

ACCESS-CONTROL-MAX-AGE None

ACCESS-CONTROL-ALLOW-CREDENTIALS Disabled

I am getting CORS errors when a page at say https://mydomain.com tries to make an Ajax request(GET) to https://hammerhead-app-ruqkl.ondigitalocean.app/. Looking in the developer console I do not see any access-control-allow-origin header being sent.

Any help and guidance will be appreciated.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 17, 2022

Hi there,

I believe that in order to use a custom domain name, you need to first follow the steps here on how to add your domain to your app:

https://docs.digitalocean.com/products/app-platform/how-to/manage-domains/

Then after that you could follow the steps here on how to configure your CORS:

https://docs.digitalocean.com/products/app-platform/how-to/configure-cors-policies/

Also, make sure to add content-type header in Access-Control-Allow-Headers.

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up