according to https://www.digitalocean.com/docs/app-platform/how-to/use-environment-variables/, I should have access to the APP_URL in the system environments

In my service component, when I do set, there’s no APP_URL in the list of system envs.

Where is it?

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.

×
1 answer

👋 Hello,

Thanks for the question, that part could be a bit more clear. The variables outlined on that page aren’t expressed directly, but rather are available for templating into environment variables you specify. This allows you to use these values in variable names your app already expects, and also allows you to format the variables as needed.

To set environment variables, go to the “Components” tab of your app, scroll to “Environment Variables”, and click “Edit”. In the key, you can specify the name of any environment variable needed by your application. In the value you can specify a template which optionally includes the variables outlined in the “How to use environment variables” page.

For example, I could put “SITE_ADDRESS” in the key section, and “${APP_DOMAIN}” in the value section and my app would set would show something like SITE_ADDRESS=example-app-000000.ondigitalocean.app. You can also build more complex variables, like database connection strings which reference components by name, for example key “API_SERVICE_ADDRESS”, value “http://${api.PRIVATE_DOMAIN}:${api.PRIVATE_PORT}/api” might yield something like “API_SERVICE_ADDRESS=http://api:80/api”. For your APP_URL example, you would simply create a variable with key “APP_URL” and value “${APP_URL}” to yield API_SERVICE_ADDRESS=https://example-app-000000.ondigitalocean.app.

Submit an Answer