By Phill
Hello I am using the Apps to serve a static website and want it to connect to an API
I am following the instructions
here https://docs.digitalocean.com/products/app-platform/reference/app-spec/
and here https://docs.digitalocean.com/products/app-platform/how-to/configure-cors-policies/
also https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/app#cors
But the format provided is not accepted when trying to add tot the Apps “App Spec” document Any ideas please
(also I added to the code from “services:” down the rest is pre-generated).
alerts:
- rule: DEPLOYMENT_FAILED
- rule: DOMAIN_FAILED
- disabled: true
rule: DEPLOYMENT_STARTED
- rule: DEPLOYMENT_LIVE
- rule: DOMAIN_LIVE
domains:
- domain: www.mywebsite.co.uk
type: PRIMARY
- domain: app.mywebsite.co.uk
type: ALIAS
- domain: admin.mywebsite.co.uk
type: ALIAS
ingress:
rules:
- component:
name: mywebsite-web-app-live
match:
path:
prefix: /
name: mywebsite-web-app-live
region: lon
static_sites:
- catchall_document: index.html
environment_slug: html
github:
branch: main
deploy_on_push: true
repo: MYCOMPANY/mywebsite-web-app-live
name: mywebsite-web-app-live
source_dir: /
services:
- cors:
allow_origins:
- prefix: https://api.mywebsite.co.uk
- prefix: https://*.mywebsite.co.uk
- prefix: https://mywebsite.co.uk
Also this link appiles you can use a UI to add cors but there is no option so might be outdated
https://docs.digitalocean.com/products/app-platform/how-to/configure-cors-policies/
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.
This comment has been deleted
Hey Phil, the CORS policies have moved under ingress rules. When you add a rule for your static site component, e.g.:
ingress:
rules:
- component:
name: mywebsite-web-app-live
match:
path:
prefix: /
add your CORS policy in the rule:
ingress:
rules:
- component:
name: mywebsite-web-app-live
match:
path:
prefix: /
cors:
allow_origins:
- prefix: https://api.mywebsite.co.uk
- prefix: https://*.mywebsite.co.uk
- prefix: https://mywebsite.co.uk
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.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
