anomalyco/sst · error

Found "base" configured in vite.config.ts but missing "basen

Error message

Found "base" configured in vite.config.ts but missing "basename" in react-router.config.ts. Both configurations are required.

What it means

React Router (v7/framework mode) requires a matching basename in react-router.config.ts when vite.config.ts sets a base. The component validates both are set together; a vite base without a react-router basename throws this Error.

Source

Thrown at platform/src/components/aws/react.ts:439

      })();

      // Get base configured in react-router config ie. "/docs/"
      const reactRouterBase = (() => {
        try {
          const rrConfig = path.join(outputPath, "react-router.config.ts");
          const content = fs.readFileSync(rrConfig, "utf-8");
          const match = content.match(/["']?basename["']?:\s*["']([^"]+)["']/);
          return match ? match[1] : undefined;
        } catch (e) { }
      })();

      if (viteBase) {
        if (!viteBase.endsWith("/"))
          throw new Error(
            `The "base" value in vite.config.ts must end with a trailing slash ("/"). This is required for correct asset path construction.`,
          );
        if (!reactRouterBase)
          throw new Error(
            `Found "base" configured in vite.config.ts but missing "basename" in react-router.config.ts. Both configurations are required.`,
          );
      }
      if (reactRouterBase) {
        if (reactRouterBase.endsWith("/"))
          throw new Error(
            `The "basename" value in react-router.config.ts must not end with a trailing slash ("/"). This ensures the root URL is accessible without a trailing slash.`,
          );
        if (!viteBase)
          throw new Error(
            `Found "basename" configured in react-router.config.ts but missing "base" in vite.config.ts. Both configurations are required.`,
          );
      }

      return {
        base: reactRouterBase,
        server: serverPath
          ? (() => {

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Add basename: "/app" (matching the vite base, no trailing slash) to react-router.config.ts
  2. Keep both values consistent (base "/app/" ↔ basename "/app")
  3. If base isn't needed, remove it from vite.config.ts

Example fix

// react-router.config.ts before
export default {};
// after
export default { basename: "/app" };
Defensive patterns

Strategy: validation

Validate before calling

if (viteBase && !basename) throw new Error("basename required in react-router.config.ts when vite base is set");

Try / catch

try {
  new sst.aws.React("Web", args);
} catch (e) {
  if (String(e).includes("missing \"basename\"")) console.error("Add matching basename to react-router.config.ts");
  throw e;
}

Prevention

When it happens

Trigger: viteBase is present (truthy) in vite.config.ts while reactRouterBase is missing/falsy in react-router.config.ts during buildPlan.

Common situations: Adding base for CDN/asset prefixing but forgetting basename; teams unaware both files must agree when using React Router framework mode.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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