---
title: "Self-host and add domains"
description: "Point the app at a self-hosted Convex backend or at custom domains for the deployment, where the HTTP-actions origin cannot be derived, and move the provider webhooks with it."
canonical_url: "https://nuxt-backend.dev/docs/ship/deploy/self-hosting"
---
# Self-host and add domains

> Point the app at a self-hosted Convex backend or at custom domains for the deployment, where the HTTP-actions origin cannot be derived, and move the provider webhooks with it.

Version: nuxt-backend 0.6.x · Tab: Ship · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

The module derives the deployment's two origins from its Convex cloud URL. The client talks to `https://<slug>.convex.cloud`, and HTTP actions answer on `https://<slug>.convex.site`: the auth routes, the webhooks, the AI stream and the health check. A custom domain or a self-hosted backend breaks that derivation. Then you name the HTTP-actions origin yourself, and move what points at it.

## Add custom domains

Set the custom domains in the Convex dashboard's deployment settings, a Professional plan feature ([Convex](https://nuxt-backend.dev/docs/services/convex#costs-and-limits)). Once the deployment answers on them, set both origins on the Nuxt host:

<table>
<thead>
  <tr>
    <th>
      Variable
    </th>
    
    <th>
      Value
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        NUXT_PUBLIC_BACKEND_URL
      </code>
    </td>
    
    <td>
      The custom domain that replaces <code>
        <slug>.convex.cloud
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        NUXT_PUBLIC_CONVEX_SITE_URL
      </code>
    </td>
    
    <td>
      The custom domain that replaces <code>
        <slug>.convex.site
      </code>
      
      . The Convex module the package runs on reads this name, and the <code>
        /api/auth
      </code>
      
       proxy and the AI stream follow it
    </td>
  </tr>
</tbody>
</table>

Then move what names the HTTP-actions origin:

- **The provider webhooks.** They live on that origin: `https://<your-http-actions-domain>/billing/events` and `/email/events`. `npx nuxt-backend billing sync --env production --webhook https://<your-http-actions-domain>/billing/events` provisions the billing endpoint there. `npx nuxt-backend email sync --prod --webhook https://<your-http-actions-domain>/email/events` points Resend's there ([Resend](https://nuxt-backend.dev/docs/services/resend#link-it)).
- **The security headers.** The module adds the deployment's origins to the Content Security Policy from the runtime config, so the policy lets the custom domains in once the host has them. `doctor --prod` checks the live page with `site-csp` and `site-backend-url`.

`SITE_URL`, on the deployment, is the app's origin, not the deployment's. It changes only when the app itself moves to another domain. `auth.config.ts` reads the deployment's own `CONVEX_SITE_URL` at runtime for its issuer and its keys' URL, so there is nothing to edit there.

## Self-host the backend

With `CONVEX_SELF_HOSTED_URL`, the Convex CLI's own name, set where the CLI and the app read it, the module derives the client URL. The HTTP-actions origin of a self-hosted backend can't be predicted. Set `NUXT_PUBLIC_CONVEX_SITE_URL` as above, and point the webhooks at it.

A self-hosted backend runs the same functions and components. What the cloud dashboard gives you is yours to run:

- **AI.** The Convex AI Gateway is not available on a self-hosted backend. Set `AI_GATEWAY_API_KEY` to a Vercel AI Gateway key ([Choose a model](https://nuxt-backend.dev/docs/build/ai/models)).
- **Backups.** The Convex CLI's export and import work the same way ([Back up, restore and roll back](https://nuxt-backend.dev/docs/ship/operate/backup)).
- **Error reports.** The actions' own reports reach `MONITORING_DSN` wherever the backend runs. Exception reporting for queries and mutations is a setting of Convex's cloud dashboard ([Monitoring](https://nuxt-backend.dev/docs/ship/operate/monitoring#what-gets-reported)).
- **A proxy in front.** It must set `x-forwarded-for` to the visitor's address, and `PROTECTION_PROOF_SECRET` must be on both the app's server and the deployment, or every caller shares one rate-limit bucket ([Rate limits](https://nuxt-backend.dev/docs/ship/security/rate-limits#privileged-routes)).

<tip>

Prerendering: an app's docs and marketing pages can prerender, but pages that open live Convex subscriptions must not (`routeRules: { '/app/**': { prerender: false } }`). Otherwise the crawler keeps WebSockets open and `nuxt build` never exits ([Troubleshooting](https://nuxt-backend.dev/docs/ship/operate/troubleshooting#nuxt-build-or-generate-never-exits)).

</tip>

## Related

- [Deploy to production](https://nuxt-backend.dev/docs/ship/deploy): the build command and the env split.
- [Register webhooks](https://nuxt-backend.dev/docs/ship/security/webhooks): the routes on the HTTP-actions origin.
- [Security model](https://nuxt-backend.dev/docs/ship/security#content-security-policy): the policy the module extends with the deployment's origins.
- [Environment variables](https://nuxt-backend.dev/docs/reference/configuration/environment-variables): every name the app and the deployment read.
- [Convex](https://nuxt-backend.dev/docs/services/convex): the account, deploy keys and self-hosting names.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
