anomalyco/sst · error · VisibleError

Cannot route the site using the provided router. The Router

Error message

Cannot route the site using the provided router. The Router component uses inline routes which has been deprecated.

What it means

SST's Router component deprecated inline routes (routes defined directly inside the Router's `routes` prop). When another component (e.g. a site or bucket) is routed through a Router whose instance reports `_hasInlineRoutes`, SST refuses to route it, because routing targets now must be standalone Router instances rather than inline route entries.

Source

Thrown at platform/src/components/aws/router.ts:3234

  router: Input<Router>;
  domain?: Input<string>;
  path?: Input<string>;
};

export function normalizeRouteArgs(
  route?: Input<RouterRouteArgs>,
  routeDeprecated?: Input<RouterRouteArgsDeprecated>,
) {
  if (!route && !routeDeprecated) return undefined;

  return all([route, routeDeprecated]).apply(([route, routeDeprecated]) => {
    const v = route
      ? route
      : { ...routeDeprecated, instance: routeDeprecated!.router };

    return v.instance._hasInlineRoutes.apply((hasInlineRoutes) => {
      if (hasInlineRoutes)
        throw new VisibleError(
          "Cannot route the site using the provided router. The Router component uses inline routes which has been deprecated.",
        );

      const pathPrefix = v.path
        ? "/" + v.path.replace(/^\//, "").replace(/\/$/, "")
        : undefined;
      return {
        hostPattern: v.domain
          ? v.domain
              .replace(/[.+?^${}()|[\]\\]/g, "\\$&") // Escape special regex chars
              .replace(/\*/g, ".*") // Replace * with .*
          : undefined,
        pathPrefix,
        routerDistributionId: v.instance.nodes.cdn.nodes.distribution.id,
        routerUrl: v.instance.url.apply(
          (url) =>
            (v.domain ? `https://${v.domain}` : url) + (pathPrefix ?? ""),
        ),

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Move inline routes out of the Router component into separate `sst.aws.Router` instances and route to that instance instead
  2. Remove the deprecated `route` shorthand and pass the Router component instance directly as `router`
  3. Check the Router docs for the current routing API and update the site's `router`/`route` args

Example fix

// before
new sst.aws.Router("Web", { routes: { "/api": "https://api.example.com" } });
new sst.aws.Astro("Site", { route: router });
// after
const apiRouter = new sst.aws.Router("Api", { domain: "api.example.com" });
new sst.aws.Astro("Site", { router: apiRouter });
Defensive patterns

Strategy: validation

Validate before calling

// before routing, inspect router config
const usesInlineRoutes = "routes" in routerArgs && routerArgs.routes;
if (usesInlineRoutes) throw new Error("Move inline routes to separate sst.aws.Router instances before routing a site.");

Prevention

When it happens

Trigger: Passing a `route`/`router` argument that points at a Router created with inline `routes: { ... }` entries, or a deprecated route object (`routeDeprecated`) whose `instance.router` has inline routes configured, when calling routing on a site/bucket component.

Common situations: Migrating older SST v1-style configs where domains/routes were declared inline on the Router; copying old examples; upgrading sst and old Router config still present.

Related errors


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