---
title: "React, Vue or Angular: connect and try it"
description: "Connect your frontend to your backend and check that login works."
url: "/sdk-integration-spa-connect/"
language: "en"
guide: "React, Vue, Angular (+ backend)"
step: "Quickstart step 3 of 4, required"
---

# Connect and try it

The last step: make your frontend reach your backend, and check that login works end to end.

## Connect your frontend to your backend

**In development (localhost):**

The widget calls `/auth/blockauth` on the **same origin** as your page, so the session cookie travels with every request. In development your frontend (your App URL) and backend usually run on different ports: proxy those routes to the port your backend already listens on, with your dev server’s proxy:

#### React · Vite

**vite.config.js · at your frontend root · add only server.proxy**

```javascript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
  server: {
    proxy: { '/auth/blockauth': 'http://localhost:4000' },
  },
})
```

#### React · Next.js

**next.config.js · at the project root · add only rewrites**

```javascript
const nextConfig = {
  async rewrites() {
    if (process.env.NODE_ENV !== 'development') return []
    return [{ source: '/auth/blockauth/:path*', destination: 'http://localhost:4000/auth/blockauth/:path*' }]
  },
}

export default nextConfig
```

#### React · Create React App

**package.json · of your frontend · add only "proxy"**

```json
{
  "proxy": "http://localhost:4000"
}
```

#### Vue · Vite

**vite.config.js · at your frontend root · add only server.proxy**

```javascript
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [vue()],
  server: {
    proxy: { '/auth/blockauth': 'http://localhost:4000' },
  },
})
```

#### Angular

**proxy.conf.json · new file at your frontend root**

```json
{
  "/auth/blockauth": { "target": "http://localhost:4000", "secure": false }
}
```

**Terminal · start the frontend with the proxy**

```bash
ng serve --proxy-config proxy.conf.json
```

> Only for development. `4000` is the port your backend already listens on: change it in your data if it isn’t.
>
> Use the port your backend already listens on. Defaults in the examples: Node.js `4000`, PHP `8080`, Python (Flask) `5000`, Python (FastAPI) `8000`, .NET `5000`.

This isn’t used in production: with Production in your settings, this section shows how to serve it from your domain.

**In production (your domain):**

The widget calls `/auth/blockauth` on the **same origin** as your page, so the session cookie travels with every request. In production you get that by serving everything from your domain, in one of these two ways:

- **Your backend serves the frontend build.** Build it (`npm run build`) and have your backend serve that folder. Nothing else needed.
- **Frontend and backend run separately.** Your reverse proxy sends `/auth/blockauth` to your backend. For example, with Nginx:

**Nginx · Your web server · add the location to your server block**

```nginx
server {
  server_name your-app.com;

  location /auth/blockauth/ {
    proxy_pass http://127.0.0.1:4000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}
```

> **Placeholders in this code:**
>
> - Replace `your-app.com` with your domain, or fill in your data in the SDK Quickstart and it is filled in for you.
> - `127.0.0.1` is your own server: change it if your backend runs on another machine. The port is the Backend port from your data, the one your server already uses.

With `https` on a proxy in front, your backend must know it to send the secure cookie: see [Go live](/sdk-integration-spa-go-live.md#production-domain).

## Try it

1. **In development (localhost):** Start your frontend and your backend. **In production (your domain):** Deploy your frontend and your backend on your domain.
2. Open your app, press the Block-Auth button and sign in.
3. Open `https://your-app.com/auth/blockauth/me` in the same browser: it must return your user.

**If it does, it works in development.** The last step is [Go live](/sdk-integration-spa-go-live.md): the same, with your production keys and domain.

If it doesn’t work:

- **You see your app’s page or a `404`**: the request doesn’t reach your backend. Check the connection above and that your backend is running.
- **`401` after signing in**: the login didn’t create the session. Go over your [backend checklist](/sdk-integration-spa-backend.md#server-checks).

Next step: [Go live](/sdk-integration-spa-go-live.md)
