Skip to main content

Testing Local Apps

Swarm’s AI agents run in the cloud. To test a local development server, the CLI automatically creates a secure tunnel from your machine to the cloud.

Basic local testing

Just pass your localhost URL:
The CLI detects that the URL is local, opens a tunnel, and rewrites the URL for the cloud agents. No configuration needed.

Persistent tunnel hostnames

If your Swarm workspace has persistent tunnels enabled, swarm login automatically provisions a stable hostname for your local tests:
Future localhost tests reuse that hostname instead of creating a fresh temporary tunnel URL each time. This is especially useful for OAuth callbacks and other redirect flows. Learn more in Persistent Tunnels.

Tunnel providers

Swarm supports two tunnel providers:

Cloudflare Tunnel (default)

Free, no bandwidth limits, no account required. Requires the cloudflared binary:

ngrok

Bundled with the CLI — works out of the box with your Swarm account. Has bandwidth limits on free ngrok plans.

Choosing a provider

Split frontend/backend

Many apps run the frontend and backend on separate ports. For example, a React app on port 3000 and an Express API on port 8080. The problem: the tunnel only exposes one port. If your frontend makes API calls to localhost:8080, the cloud browser can’t reach it. The solution: Swarm’s built-in reverse proxy routes API paths to your backend through the same tunnel.
This starts a proxy that routes:
  • /api/*, /auth/*, /graphql, /trpc/*localhost:8080 (backend)
  • Everything else → localhost:3000 (frontend)

Custom API paths

If your backend uses different path prefixes:

Skipping the tunnel

If your URL is already publicly accessible:

Framework notes

Next.js / Nuxt / SvelteKit / Remix

These full-stack frameworks serve both frontend and API routes on the same port. You typically don’t need the --backend flag — a single tunnel covers everything.

Django

Add the tunnel URL to your ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS in settings.py. The CLI prints a reminder with the exact values after the tunnel opens.

Vite / Create React App

If your frontend proxies API calls in development (e.g., Vite’s server.proxy), the proxy already handles routing and a single tunnel works. Only use --backend if you’re making direct cross-origin requests to a separate backend port.