Environments & deploy
App keys are per-deployment, so staging and production need their own keys and URLs. The clean way to manage this is a committed env file per environment, loaded at build time by your bundler or framework.
Per-environment config
Section titled “Per-environment config”Create committed env files (publishable keys + URLs are public):
MUHKOO_BASE_URL=https://api.staging.muhkoo.devMUHKOO_KEY=mk_test_pk_… # minted against STAGINGMUHKOO_KEY=mk_live_pk_… # minted against PRODUCTION# MUHKOO_BASE_URL is optional — it defaults to the hosted accelerator# (https://api.muhkoo.dev), so production usually doesn't need to set it.MUHKOO_BASE_URL is only required to point the client at a non-default
accelerator — staging above, or a self-hosted deployment. When it’s unset, the
client uses the hosted accelerator.
Build each deployment against its matching env file — most bundlers and frameworks support per-environment env files. Wire one build script per environment so the right file is loaded:
{ "scripts": { "build:staging": "<your build command, loading .env.staging>", "build:production": "<your build command, loading .env.production>" }}const client = new Client({ apiKey: process.env.MUHKOO_KEY, baseUrl: process.env.MUHKOO_BASE_URL,});Deploying
Section titled “Deploying”Deploy each build to its own target so staging and production never overwrite each other — give them separate site names (and hostnames). Wire a deploy script per environment that builds with the matching env file, then ships:
{ "scripts": { "deploy:staging": "npm run build:staging && <your deploy command for staging>", "deploy:production": "npm run build:production && <your deploy command for production>" }}If your app is a single-page app, configure your host to fall back to
index.html for unknown routes so client-side routing keeps working.
Custom domains
Section titled “Custom domains”Point each environment at its own hostname — e.g. app.example.com for
production and app-staging.example.com for staging — through your host’s
domain settings, and make sure TLS is provisioned for each before going live.
Minting per-environment keys
Section titled “Minting per-environment keys”Issue a key from the developer portal pointed at
the target environment, then drop the pk into that env file. Because keys are
per-deployment, a staging key returns API key required against production and
vice-versa — if auth/messaging 401s, check you’re using the key for the right
environment.