Go live
Your code doesn’t change: only the keys, the variables and the domain do. Here are just those changes, with your production data.
What changes
1. Validate your domain and use the Production keys
In the Dashboard, validate your domain. Then copy the Production data with Copy data for the guide and paste it into your data: it fills in the Production row.
2. Put the variables on your server
In production don’t use your computer’s .env: set them as environment variables on your server or platform (Docker, your hosting…). Generate a new SESSION_SECRET, different from the development one.
Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
Replace the API Secret placeholder with your API Secret, copied straight from the Dashboard. Never paste it on this site.
Replace the SESSION_SECRET placeholder with a random value generated on your computer: openssl rand -hex 32.
Replace your_api_key with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.
Replace https://your-app.com with your app URL, or fill in your data in the SDK Quickstart and it is filled in for you.
Your frontend apiKey is baked in at build time: build with the production one.
It’s baked into the build, so it must exist where you build for production. Pick how you build:
npm run build loads it on its own, and npm run dev keeps using your development .env. You can commit it: the apiKey is public, it ends up in the JavaScript every browser downloads.
VITE_BLOCKAUTH_API_KEY=your_api_keyReplace your_api_key with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.
3. Serve everything from your domain, over https
There’s no dev proxy in production. Either your backend serves the frontend build, or your reverse proxy (Nginx, your load balancer) sends /auth/blockauth to your backend. Then make sure the session cookie is marked secure. The examples without the package already do it from APP_URL; with the package, it depends on your backend:
- In your
session(...), addsecure: truetocookie. - If a proxy terminates
httpsin front of your backend, addapp.set('trust proxy', 1). Without it, Express doesn’t send the secure cookie and/meanswers401.
4. Allow the widget in your Content Security Policy
If your server sends a Content-Security-Policy header (many frameworks, proxies and security templates add one), the browser blocks the widget until you allow it. You won't notice in development, because the frontend dev server doesn't send it: it shows up after deploying, with an unstyled button, a broken logo and a failing login. Check with curl -sI https://your-domain | grep -i content-security-policy; if it returns nothing, skip this step.
Add these directives to the CSP you already send, keeping yours. If you already have one of them, add only the missing sources: If you set wsUrl (another Block-Auth server), write its host instead of wss.block-auth.io in connect-src, over https and wss.
Content-Security-Policy
connect-src 'self' https://wss.block-auth.io wss://wss.block-auth.io;
img-src 'self' data:;
style-src 'self' 'unsafe-inline';
connect-src: the widget askswss.block-auth.iofor the login link, overhttpsandwss;'self'covers yourauthEndpoint.img-src: the Block-Auth logo in the button, embedded as adata:image.style-src: the widget injects its styles in a<style>tag. It only allows inline CSS, not JavaScript:script-srccan stay as strict as you have it.
The login opens on auth.block-auth.io, in a popup or in the same tab if the browser blocks popups, so you don't need to allow Google, Microsoft or the wallets. If your site sends Cross-Origin-Opener-Policy, use same-origin-allow-popups, not same-origin: otherwise your page can't receive the result from the popup.
5. Check the webhook, if you use it
In your production app in the Dashboard, the webhook path is the same, /auth/blockauth/webhook, on your public domain.
6. Try it
Same as in development, but on your domain: sign in with the Block-Auth button and open http://localhost:5173/auth/blockauth/me. It must return your user. If the button has no styles, a broken logo, or the login says it failed, open the browser console (F12): a violates the following Content Security Policy directive message means step 4 is missing.
Before you publish
Go over this before opening your app to your users:
- Your production app has its own validated domain and keys, and the site uses
https. - The
apiSecretis only in your backend's environment, never in the frontend bundle. /codechecks thatredirectUriis on your origin, and your app creates sessions only from the address returned by/api/auth/token.- The session cookie is
HttpOnly,SecureandSameSite=Lax. - If your server sends a CSP, allow the widget as in step 4, and if it sends
Cross-Origin-Opener-Policy, it'ssame-origin-allow-popups.
With this, the integration is done. What follows under More options is optional: add it when your app needs it.
What the package already covers
If you use the Block-Auth package in your backend, it already does this for you:
- Trusts only Block-Auth. The user always comes from redeeming the code with your
apiSecret, and theredirectUrimust be onappUrl. If your frontend lives on several origins, passallowedOrigins(a list) instead. - Blocks forged requests. It only accepts
POSTrequests with a JSON body, so another site can't log your users in with a form. - Keeps the session short and clean. It renews the session ID on every login and ends it when the user's Block-Auth signature expires (
signedExpiredAt). To end it earlier, setmaxSessionSeconds(MaxSessionDurationin .NET). - Logs out everywhere.
POST /logoutalso closes the user's Block-Auth sessions for your app, and keeps the rest of your session data. - Verifies every webhook. Signature, time and
apiKey, before calling your code.

