Use web service URL as environment variable

Hi all,

I’m running three services using a render.yaml blueprint file. I have an Postgres DB, a Python API, and a Vue frontend (static site).

Is it possible to reference the API endpoint as an environment variable in the blueprint file? Something like https://my-api.onrender.com.

I’ve tried the following:

    envVars:
        fromService:
          type: web
          name: my-api
          property: host

But this doesn’t give the URL I need, just the name of the service. Is there a full list of all possible environment variables available anywhere? The specs in Blueprint Specification | Render seem incomplete.

Thanks for any help!

You want to use something like this:

envVars:
- key: MY_API_ENDPOINT
  fromService:
    type: web
    name: my-api
    envVarKey: RENDER_EXTERNAL_URL

Note that if you’re using custom domain for the API, you’ll probably have to specify that as a CUSTOM_DOMAIN (for example) env var on your API service and then change the RENDER_EXTERNAL_URL above to CUSTOM_DOMAIN key name.

2 Likes

Great thanks so much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.