anomalyco/sst · error · VisibleError

Cannot provide both "domain" and "route". Use the "domain"…

Error message

Cannot provide both "domain" and "route". Use the "domain" prop on the "Router" component when serving your site through a Router.

What it means

When an SSR site is served through a `Router` via the `route` prop, custom domain configuration must live on the Router itself. Passing both `domain` on the site and `route` is ambiguous and rejected at construction time with this message pointing you to set domain on the Router.

Solutions

  1. Remove the `domain` prop from the site component
  2. Move the domain configuration to the Router component (`new sst.aws.Router("Router", { domain: "example.com" })`)
  3. Deploy again

Example fix

// before
new sst.aws.NextjsSite("Web", {
  path: "src",
  domain: "app.example.com",
  route: { router },
});
// after
new sst.aws.NextjsSite("Web", {
  path: "src",
  route: { router }, // router created with { domain: "app.example.com" }
});
Defensive patterns

Strategy: validation

Validate before calling

if (siteArgs.domain && siteArgs.route) {
  throw new Error('Set `domain` on the Router component instead of the site when using `route`');
}

Try / catch

try {
  new sst.aws.NextjsSite("Web", args);
} catch (e) {
  if (String(e).includes('Cannot provide both "domain" and "route"')) console.error("Move domain to the Router");
  throw e;
}

Prevention

When it happens

Trigger: An SSR site component args include both `domain: {...}` and `route: { router }` (or `router`), e.g. after partially migrating from domain-based to router-based serving.

Common situations: Following old docs that set `domain` while also adopting a Router; merging config changes where one teammate added a router and another kept the domain.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/c9ca783dcfc281cc. Report an issue: GitHub.

Appendix: source

Thrown at platform/src/components/aws/ssr-site.ts:1259

            throw new VisibleError(
              `Region ${region} is not supported by this component. Please select a different AWS region.`,
            );

          if (!Object.values(Region).includes(region as Region))
            throw new VisibleError(
              `Invalid AWS region: "${region}". Please specify a valid AWS region.`,
            );
          return region as Region;
        });
      });
    }

    function normalizeRoute() {
      const route = normalizeRouteArgs(args.router, args.route);

      if (route) {
        if (args.domain)
          throw new VisibleError(
            `Cannot provide both "domain" and "route". Use the "domain" prop on the "Router" component when serving your site through a Router.`,
          );

        if (args.edge)
          throw new VisibleError(
            `Cannot provide both "edge" and "route". Use the "edge" prop on the "Router" component when serving your site through a Router.`,
          );

        if (args.protection)
          throw new VisibleError(
            `Cannot set "protection" when routing through a Router. Set "protection" on the Router component instead.`,
          );
      }

      return route;
    }

    function normalizeEdge() {

View on GitHub (pinned to a0bd20f762)