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

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:

vite.config.js · at your frontend root · add only server.proxy
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

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

Only for development. 4000 is the port your backend already listens on: change it in your data if it isn’t.

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

Try it

  1. Start your frontend and your backend.
  2. Open your app, press the Block-Auth button and sign in.
  3. Open http://localhost:5173/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: 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.