How it works
Each service gets its sibling services’ URLs automatically. To reach an addon or another setting, a service references it with a template, and Locus fills in the value at deploy time.Set variables
Add variables in the dashboard or through the API, then redeploy so your running app picks them up.PATCH /v1/variables/service/{serviceId}adds or updates values and keeps the rest.PUTon the same route replaces every variable for the service.- Keep secrets server-side and out of committed
.locusbuildfiles.
Service-to-service references
For a service namedapi, other services get:
API_URLfor public HTTPS requests, including browser calls.API_INTERNAL_URLfor internal server-to-server requests.
LOCUS_SERVICE_URL, its own public URL. Names are uppercased, with non-alphanumeric characters replaced by underscores.
Template syntax
For example, setDATABASE_URL to ${{db.DATABASE_URL}} to connect to a Postgres addon named db.
- Addon templates also expose
HOSTandPORT; Postgres addsUSERNAMEandDATABASE. - Only services with an explicit addon reference receive its connection variables.
- Wait until the addon is
availablebefore deploying a service that references it.
Full-stack .locusbuild example
This connects an API to Postgres and Redis, and a frontend to the API, as in the diagram above:.locusbuild
Variable scopes
When the same name exists in more than one scope, service variables win over environment variables, which win over addon variables.Get resolved variables
To preview the final values before deploying, useGET /v1/variables/service/{serviceId}/resolved. Treat the response as sensitive: it can contain credentials. See the Build API reference for every variable operation.
Next steps
Addons
Create the Postgres or Redis addon to reference.
Services
Configure the services that use these variables.