---
title: "React, Vue or Angular: go live"
description: "The checks before publishing your integration."
url: "/sdk-integration-spa-go-live/"
language: "en"
guide: "React, Vue, Angular (+ backend)"
step: "Quickstart step 4 of 4, required"
---

# 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.

Every example on this page uses the production values: the production API Key and API Secret and the app’s real domain.

## What changes

### 1. Validate your domain and use the Production keys

In the Dashboard, [validate your domain](/integration-quickstart.md#apps-validate-domain). Then copy the **Production** data with **Copy data for the guide** and paste it into [your data](/sdk-integration.md#setup): 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.

`APP_URL` in development is the URL where your frontend runs: Vite `http://localhost:5173`, Next.js `http://localhost:3000`, Create React App `http://localhost:3000`, Angular `http://localhost:4200`.

#### Node.js · development

In a .env next to your backend package.json. Load it with `node --env-file=.env` (Node 20.6+) or the `dotenv` package (`import 'dotenv/config'` at the top of your entry file).

**Your backend’s .env · in your backend folder**

```dotenv
APP_URL=http://localhost:5173
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Node.js · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
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>
```

#### PHP · development

getenv() doesn't read .env files by itself: set them in your server (`SetEnv` in Apache, `env[]` in PHP-FPM), or load the .env with `vlucas/phpdotenv`.

**Your backend’s .env · in your backend folder**

```dotenv
APP_URL=http://localhost:5173
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

#### PHP · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

#### Python (Flask) · development

In a .env in your backend folder. `flask run` loads it if `python-dotenv` is installed; with `python app.py`, gunicorn or waitress, call `load_dotenv()` first, use `uv run --env-file .env …` or export the variables.

**Your backend’s .env · in your backend folder**

```dotenv
APP_URL=http://localhost:5173
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Python (Flask) · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
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>
```

#### Python (FastAPI) · development

In a .env in your backend folder. Start uvicorn with `--env-file .env` (needs `python-dotenv` installed) or, with uv, `uv run --env-file .env uvicorn …`, or export the variables.

**Your backend’s .env · in your backend folder**

```dotenv
APP_URL=http://localhost:5173
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Python (FastAPI) · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
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>
```

#### .NET · development

The public values go in `appsettings.json`. The secret never goes in a file you commit: in development use `user-secrets`, in production an environment variable.

**appsettings.json**

```json
{
  "APP_URL": "http://localhost:5173",
  "BLOCKAUTH_API_KEY": "your_api_key"
}
```

**Terminal, in the project folder (development only)**

```bash
dotnet user-secrets init
dotnet user-secrets set "BLOCKAUTH_API_SECRET" "<paste the API Secret from the Dashboard>"
```

#### .NET · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**appsettings.json**

```json
{
  "APP_URL": "https://your-app.com",
  "BLOCKAUTH_API_KEY": "your_api_key"
}
```

**Environment variable on your server (never in a repo file)**

```dotenv
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

> **Placeholders in this code:**
>
> - 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.

#### Vite (React · Vue) · development

This is your frontend’s `.env`. The backend has its own file.

**.env, next to the frontend package.json**

```dotenv
VITE_BLOCKAUTH_API_KEY=your_api_key
```

#### Vite (React · Vue) · production

It’s baked into the build, so it must exist where you build for production. Pick how you build:

**File · .env.production · in your frontend folder**

```dotenv
VITE_BLOCKAUTH_API_KEY=your_api_key
```

**Docker · Dockerfile · right before npm run build**

```dotenv
ARG VITE_BLOCKAUTH_API_KEY
RUN npm run build
```

**Docker · docker-compose.yml · in the service that builds your frontend**

```dotenv
build:
  args:
    VITE_BLOCKAUTH_API_KEY: ${BLOCKAUTH_API_KEY}
```

**CI · Variable of your CI · in the job that runs npm run build**

```dotenv
VITE_BLOCKAUTH_API_KEY=your_api_key
```

#### Next.js (React) · development

This is your frontend’s `.env.local`. The backend has its own file.

**.env.local, at the project root**

```dotenv
NEXT_PUBLIC_BLOCKAUTH_API_KEY=your_api_key
```

#### Next.js (React) · production

It’s baked into the build, so it must exist where you build for production. Pick how you build:

**File · .env.production · in your frontend folder**

```dotenv
NEXT_PUBLIC_BLOCKAUTH_API_KEY=your_api_key
```

**Docker · Dockerfile · right before npm run build**

```dotenv
ARG NEXT_PUBLIC_BLOCKAUTH_API_KEY
RUN npm run build
```

**Docker · docker-compose.yml · in the service that builds your frontend**

```dotenv
build:
  args:
    NEXT_PUBLIC_BLOCKAUTH_API_KEY: ${BLOCKAUTH_API_KEY}
```

**CI · Variable of your CI · in the job that runs npm run build**

```dotenv
NEXT_PUBLIC_BLOCKAUTH_API_KEY=your_api_key
```

#### Create React App (React) · development

This is your frontend’s `.env`. The backend has its own file.

**.env, at the project root**

```dotenv
REACT_APP_BLOCKAUTH_API_KEY=your_api_key
```

#### Create React App (React) · production

It’s baked into the build, so it must exist where you build for production. Pick how you build:

**File · .env.production · in your frontend folder**

```dotenv
REACT_APP_BLOCKAUTH_API_KEY=your_api_key
```

**Docker · Dockerfile · right before npm run build**

```dotenv
ARG REACT_APP_BLOCKAUTH_API_KEY
RUN npm run build
```

**Docker · docker-compose.yml · in the service that builds your frontend**

```dotenv
build:
  args:
    REACT_APP_BLOCKAUTH_API_KEY: ${BLOCKAUTH_API_KEY}
```

**CI · Variable of your CI · in the job that runs npm run build**

```dotenv
REACT_APP_BLOCKAUTH_API_KEY=your_api_key
```

#### Angular (environment.ts) · development

Angular doesn’t use .env: your apiKey goes in this file. The backend variables go in their own file, your backend’s `.env`.

**src/environments/environment.ts**

```typescript
export const environment = {
  blockauthApiKey: 'your_api_key',
}
```

#### Angular (environment.ts) · production

Keep `environment.ts` with the development key and put the production one in `environment.prod.ts`, next to it. Then tell `angular.json` to swap them in the production build (`ng build`, the default configuration), so development keeps working on `localhost`.

**src/environments/environment.prod.ts · new file**

```typescript
export const environment = {
  blockauthApiKey: 'your_api_key',
}
```

**angular.json · inside projects › your-app › architect › build › configurations › production**

```dotenv
"fileReplacements": [
  {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.prod.ts"
  }
]
```

#### apiKey written in the widget config (React · Vue · Angular) · development and production

Your apiKey goes straight into the widget config (next step), no environment file.

In the widget config, read the apiKey from that variable instead of writing `your_api_key`:

- Vite (`src/main.jsx · src/main.ts`): `apiKey: import.meta.env.VITE_BLOCKAUTH_API_KEY,`
- Next.js (`app/layout.tsx`): `apiKey: process.env.NEXT_PUBLIC_BLOCKAUTH_API_KEY,`
- Create React App (`src/index.js`): `apiKey: process.env.REACT_APP_BLOCKAUTH_API_KEY,`
- Angular (`src/app/app.config.ts`): `apiKey: environment.blockauthApiKey,`

> **Placeholders in this code:**
>
> - Replace `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:

**Only for Node.js:**

- In your `session(...)`, add `secure: true` to `cookie`.
- If a proxy terminates `https` in front of your backend, add `app.set('trust proxy', 1)`. Without it, Express doesn’t send the secure cookie and `/me` answers `401`.

**Only for PHP:**

- The package marks it secure when PHP sees `https`. If a proxy terminates `https` in front of PHP, pass it `HTTPS=on` (with Nginx and PHP-FPM, `fastcgi_param HTTPS on;`).

**Only for Python (Flask):**

- Add `SESSION_COOKIE_SECURE=True` to your Flask config.

**Only for Python (FastAPI):**

- Your `SessionMiddleware` has `https_only=True` (with `APP_URL` on `https`, the example above already does it).

**Only for .NET:**

- The package marks it secure over `https`. If a proxy terminates `https` in front of your app, add `app.UseForwardedHeaders()` with `ForwardedHeaders.XForwardedProto` before `UseAuthentication()`.

### 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 · HTTP header your server sends**

```text
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 asks `wss.block-auth.io` for the login link, over `https` and `wss`; `'self'` covers your `authEndpoint`.
- `img-src`: the Block-Auth logo in the button, embedded as a `data:` image.
- `style-src`: the widget injects its styles in a `<style>` tag. It only allows inline CSS, not JavaScript: `script-src` can 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](/sdk-integration-spa-webhooks.md) 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 `https://your-app.com/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 `apiSecret` is only in your backend's environment, never in the frontend bundle.
- `/code` checks that `redirectUri` is on your origin, and your app creates sessions only from the address returned by `/api/auth/token`.
- The session cookie is `HttpOnly`, `Secure` and `SameSite=Lax`.
- If your server sends a CSP, allow the widget as in [step 4](#production-csp), and if it sends `Cross-Origin-Opener-Policy`, it's `same-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 the `redirectUri` must be on `appUrl`. If your frontend lives on several origins, pass `allowedOrigins` (a list) instead.
- **Blocks forged requests.** It only accepts `POST` requests 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, set `maxSessionSeconds` (`MaxSessionDuration` in .NET).
- **Logs out everywhere.** `POST /logout` also 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.

This is the last required step of the guide. What follows under More options is optional.
