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!
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.
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