Environment variables
Environment variables on a site pass constants and secrets — API keys, connection strings, feature flags — to your build and to your runtime.
Setting a variable
From the CLI:
revenexx sites create-variable \
--site-id <SITE_ID> \
--key PSP_PUBLIC_KEY \
--value pk_live_...
The rest of the set, for scripting:
revenexx sites list-variables --site-id <SITE_ID>
revenexx sites get-variable --site-id <SITE_ID> --variable-id <VARIABLE_ID>
revenexx sites update-variable --site-id <SITE_ID> --variable-id <VARIABLE_ID> --value <NEW_VALUE>
revenexx sites delete-variable --site-id <SITE_ID> --variable-id <VARIABLE_ID>
Over the API:
# Create a variable on a site
curl -s -X POST 'https://api.revenexx.com/v1/sites/<SITE_ID>/variables' \
-H 'X-Revenexx-Tenant: <tenant-slug>' \
-H 'X-Revenexx-Api-Key: <api-key>' \
-H 'Content-Type: application/json' \
-d '{"key":"PSP_PUBLIC_KEY","value":"pk_live_..."}'
# List variables
curl -s 'https://api.revenexx.com/v1/sites/<SITE_ID>/variables' \
-H 'X-Revenexx-Tenant: <tenant-slug>' \
-H 'X-Revenexx-Api-Key: <api-key>'
A key can be up to 255 characters and a value up to 8192.
Variables apply to the next deployment. Setting one does not change the running build. This is the most common surprise: a variable set, a page refreshed, nothing different. Create a new deployment.
Secret variables are one-way
A variable can be marked secret, at creation or afterwards:
revenexx sites create-variable \
--site-id <SITE_ID> \
--key ERP_API_TOKEN \
--value <token> \
--secret true
Use it for anything you would not want printed in a support session. And keep a copy wherever your team keeps credentials before you set it, because the platform will not give it back.
The practical rule: if it would be a problem in a screenshot, make it secret.
Variables the platform injects for you
Every deployed site receives these at build time and at run time, without you setting anything:
| Variable | Description |
|---|---|
REVENEXX_SITE_API_ENDPOINT | API endpoint the site should call |
REVENEXX_SITE_API_KEY | Scoped API key issued to this site's runtime |
REVENEXX_SITE_ID | The site's ID |
REVENEXX_SITE_NAME | The site's name |
REVENEXX_SITE_DEPLOYMENT | ID of the running deployment |
REVENEXX_SITE_PROJECT_ID | The project the site belongs to |
REVENEXX_SITE_RUNTIME_NAME | Runtime name |
REVENEXX_SITE_RUNTIME_VERSION | Runtime version |
REVENEXX_SITE_CPUS | Runtime CPU specification |
REVENEXX_SITE_MEMORY | Runtime memory specification |
REVENEXX_SITE_API_KEY is the useful one: your server routes can call the platform with it rather than you provisioning and rotating a key by hand. It is a runtime value — read it server-side, and never expose it to the browser. See The BFF pattern.
REVENEXX_SITE_DEPLOYMENT is worth surfacing in a health endpoint or a response header. When someone asks "is this the new build?", you want an answer that doesn't require reading logs.
The variables a theme reads
A theme's own configuration comes through Nuxt's runtime config, which means NUXT_-prefixed names rather than the REVENEXX_SITE_* set:
| Variable | What it sets |
|---|---|
NUXT_REVENEXX_API_URL | The gateway to call |
NUXT_REVENEXX_TENANT | The tenant slug |
NUXT_REVENEXX_API_KEY | The key the server routes authenticate with |
NUXT_CHECKOUT_SESSION_SECRET | Signing secret for the checkout session token — set it explicitly on a multi-tenant deployment, as a secret variable |
NUXT_PUBLIC_CART_INACTIVITY_TTL | How long an idle cart survives, in milliseconds |
NUXT_PUBLIC_TAX_INCLUDED_PRICES | Whether displayed prices include tax |
NUXT_PUBLIC_* values reach the browser. Everything else is private runtime config, readable server-side only. Never move a credential under a public name.Full explanation of the local versions: Local development.
Build time versus run time
Worth being precise about, because it decides whether a change needs a rebuild:
| Static site | Server-rendered site | |
|---|---|---|
| Build time | ✓ | ✓ |
| Run time | nothing executes per request | ✓ |
A static site can only bake a variable in at build time, so changing one always means a new deployment. A server-rendered site reads run-time values per request — but the variable still only reaches the runtime on the next deployment.
Debugging
- A variable I set isn't there. It applies from the next deployment. Create one.
- I can't read a value back. It's marked secret, and that's irreversible.
- A public variable is
undefinedin the browser. OnlyNUXT_PUBLIC_*names are serialized to the client. Anything else is server-only, by design. - The site works locally and fails deployed with a 401. You're probably expecting
REVENEXX_SITE_API_KEYwhere your code readsNUXT_REVENEXX_API_KEY, or the reverse. Map one to the other explicitly.
Related
- Build configuration — what runs, and when settings take effect
- Compute specifications — the build and runtime sizes
- The BFF pattern — where a credential may and may not be read
- Local development — the same variables on your machine
- Logs — and why you should never log a variable