Deploy the Frontend
Build the static bundle and serve dist/, with an optional Docker recipe.
You build the frontend once into a static dist/ folder and serve it from any static host; there
is no server runtime. To run it locally instead, see docs/tutorials/quickstart.md.
Prerequisites
- Node.js 22+ and npm 9+ on the build machine.
npm run buildalso builds the docs site, which needs Node 22. The host that servesdist/needs nothing but static file serving. - A running
DARE backendthat the browser can reach at the URLs you configure.
Production checklist
- Set the
VITE_*values for this environment before you build. Vite inlines them into the bundle, so changing them later means rebuilding. - Set
VITE_APP_ENVIRONMENTto a valid tier (dare-staging,dare-productionorgt-production). Any other value falls back tolocal. - Use an
https://backend URL when the page is served over HTTPS; Socket.IO then upgrades towss://on the same origin. - Configure SPA fallback: rewrite every unmatched path to
/index.html. - Add the frontend's origin to the backend's
CORS_ALLOWED_ORIGINSandCSRF_TRUSTED_ORIGINS. - Serve
index.htmlwithCache-Control: no-cache. - Apply the hardening notes in the security policy.
Static host
-
Copy the env template and set the production values. docs/reference/configuration.md lists every variable.
cp .env.example .envThe minimum for a production build:
VITE_APP_ENVIRONMENT=dare-production VITE_DJANGO_BACKEND_URL=https://api.example.com -
Build.
dist/gets the hashed JS/CSS assets,index.html, and the docs site indist/docsanddist/_next.npm ci npm run build -
Serve
dist/. Every option works the same for the app:- Managed static hosting. Upload
dist/to Netlify, Vercel, Cloudflare Pages, S3 + CloudFront or Cloud Storage, and turn on the rewrite of unmatched paths to/index.htmlso React Router handles deep links. - Nginx, Apache or Caddy. Copy
dist/to the web root and add the same SPA fallback. A minimal Nginx config is under Docker and Nginx. - A quick check on a box.
npx serve -s dist -l 5173(-sturns on the SPA fallback). Fine for staging; use a real web server or CDN in production.
- Managed static hosting. Upload
Docker and Nginx
The frontend does not need a container. Use one only if the rest of your stack ships that way.
Save this as nginx.conf at the repo root. It also works on its own, without Docker:
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Content-hashed assets can be cached for a year
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# SPA fallback: React Router handles the path
location / {
try_files $uri $uri/ /index.html;
}
}A minimal multi-stage Dockerfile:
# build stage
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
ARG VITE_APP_ENVIRONMENT=dare-production
ARG VITE_DJANGO_BACKEND_URL
ENV VITE_APP_ENVIRONMENT=$VITE_APP_ENVIRONMENT
ENV VITE_DJANGO_BACKEND_URL=$VITE_DJANGO_BACKEND_URL
RUN npm run build
# serve stage
FROM nginx:1.27-alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80Pass the per-environment values as build args; changing them on a running container has no effect.
docker build \
--build-arg VITE_DJANGO_BACKEND_URL=https://api.example.com \
-t dare-frontend .
docker run -d -p 80:80 --name dare-frontend dare-frontendSocket.IO
Socket.IO connects to the VITE_DJANGO_BACKEND_URL origin (a trailing /api is stripped) at
path /socket.io/, on the /chat, /workflow and /assistant namespaces. It sends the same JWT as
REST and tries WebSocket first, then long polling. A reverse proxy in front of the backend must
pass WebSocket upgrades on /socket.io/. Backend settings are in the
backend configuration reference.
Verify
- Visit the deployed URL. The login screen loads.
- Open dev tools, go to Network, sign in, and check that:
- REST requests go to
VITE_DJANGO_BACKEND_URL - the Socket.IO upgrade succeeds (a
wss://request with status101)
- REST requests go to
- Send a chat message. Streamed tokens arrive.
- Upload a file. It moves from
processingtocompleted. - Open
/docs. The docs site loads.
If a step fails, check the browser console for CORS or auth errors and confirm the backend's
CORS_ALLOWED_ORIGINS includes your origin.
Upgrade
git pull
npm ci
npm run build
# redeploy dist/ the usual wayDARE's own servers deploy over SSH from GitHub Actions. Staging deploys on every push to dev
(.github/workflows/deploy-staging.yml, which runs the server's deploy_fe.sh, a copy of
devops/deploy.sh). Production is a manual run of .github/workflows/deploy.yml: it pulls main
on the server, runs npm run build with Node 22, moves dist/* into /var/www/dare-frontend
and restarts Nginx.
Troubleshooting
- White screen, or deep links return 404. The server has no SPA fallback. Add
try_files $uri $uri/ /index.htmlor the host's rewrite-to-index.htmlsetting. Network Erroron every request.VITE_DJANGO_BACKEND_URLis wrong, or the backend's CORS settings do not allow your origin. Check the URL and add the origin toCORS_ALLOWED_ORIGINS.- Chat connects but no tokens stream. Check that the
/socket.io/request to the backend origin upgrades (status101) and inspect the WebSocket frames in dev tools. - The build fails with type errors. The types drifted from a backend API change. Update
src/redux/types/and rerunnpm run app:buildfor the full report. - Old code is served after a deploy. A CDN or browser cache holds the old
index.html. Serveindex.htmlwithCache-Control: no-cache; Vite fingerprints the assets. - A
VITE_*value is ignored. Vite inlines it at build time. Rebuild with the new value. - The console warns
Invalid or missing VITE_APP_ENVIRONMENT. The value is not one of the valid tiers, so the app runs aslocal. Set a valid tier and rebuild.
For contributing, see .github/CONTRIBUTING.md.