DDARE Docs
How-to guides

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 build also builds the docs site, which needs Node 22. The host that serves dist/ needs nothing but static file serving.
  • A running DARE backend that 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_ENVIRONMENT to a valid tier (dare-staging, dare-production or gt-production). Any other value falls back to local.
  • Use an https:// backend URL when the page is served over HTTPS; Socket.IO then upgrades to wss:// 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_ORIGINS and CSRF_TRUSTED_ORIGINS.
  • Serve index.html with Cache-Control: no-cache.
  • Apply the hardening notes in the security policy.

Static host

  1. Copy the env template and set the production values. docs/reference/configuration.md lists every variable.

    cp .env.example .env

    The minimum for a production build:

    VITE_APP_ENVIRONMENT=dare-production
    VITE_DJANGO_BACKEND_URL=https://api.example.com
  2. Build. dist/ gets the hashed JS/CSS assets, index.html, and the docs site in dist/docs and dist/_next.

    npm ci
    npm run build
  3. 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.html so 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 (-s turns on the SPA fallback). Fine for staging; use a real web server or CDN in production.

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 80

Pass 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-frontend

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

  1. Visit the deployed URL. The login screen loads.
  2. 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 status 101)
  3. Send a chat message. Streamed tokens arrive.
  4. Upload a file. It moves from processing to completed.
  5. 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 way

DARE'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.html or the host's rewrite-to-index.html setting.
  • Network Error on every request. VITE_DJANGO_BACKEND_URL is wrong, or the backend's CORS settings do not allow your origin. Check the URL and add the origin to CORS_ALLOWED_ORIGINS.
  • Chat connects but no tokens stream. Check that the /socket.io/ request to the backend origin upgrades (status 101) 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 rerun npm run app:build for the full report.
  • Old code is served after a deploy. A CDN or browser cache holds the old index.html. Serve index.html with Cache-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 as local. Set a valid tier and rebuild.

For contributing, see .github/CONTRIBUTING.md.

On this page