Hi, I’m having CORS issues. I have a backend running in digitalocean as an App and another App running the frontend as a static site. When I’m trying to access the backend from the frontend I get a CORS error. I tried setting my backend url in the app spec as follows:
ingress:
rules:
- component:
name: guest-list-frontend
cors:
allow_origins:
- prefix: https://my-backend-app.ondigitalocean.app
match:
path:
prefix: /
Where the url mentioned in prefix is the URL of my backend. But I still get this issue. Can anybody help me out?
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!
Hey!
To set CORS headers for your static site on DigitalOcean App Platform, you need to configure CORS policies for your app’s resources. Here’s a brief guide on how to do it:
This approach will help you set the Access-Control-Allow-Origin header based on the match type you select. Keep in mind that the ‘Exact’ match type will set the header only if the client’s origin exactly matches the value you provide, while ‘Prefix’ and ‘Regex’ offer more flexibility in matching the origin.
For more detailed instructions, you can refer to DigitalOcean’s documentation on configuring CORS policies.
Hope that this helps!
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.