anomalyco/sst · error

The "basename" value in react-router.config.ts must not end

Error message

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.

What it means

Conversely to the vite base, the basename in react-router.config.ts must NOT end with a trailing slash, so the root URL works without a trailing slash. buildPlan throws this Error when reactRouterBase ends with "/".

Source

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

          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
          ? (() => {
            // React does perform their own internal ESBuild process, but it doesn't bundle
            // 3rd party dependencies by default. In the interest of keeping deployments
            // seamless for users we will create a server bundle with all dependencies included.

            fs.copyFileSync(
              path.join(

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Remove the trailing slash from basename in react-router.config.ts ("/app/" → "/app")
  2. Keep vite base with the slash and basename without it
  3. Re-run sst deploy

Example fix

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

Strategy: validation

Validate before calling

if (basename && basename.endsWith("/")) throw new Error(`react-router basename must not end with '/': ${basename}`);

Try / catch

try {
  new sst.aws.React("Web", args);
} catch (e) {
  if (String(e).includes("basename\" value in react-router")) console.error("Remove the trailing slash from basename");
  throw e;
}

Prevention

When it happens

Trigger: Setting basename: "/app/" in react-router.config.ts (mirroring vite's base with slash) during buildPlan.

Common situations: Copy-pasting the trailing-slash convention from vite base into basename; assuming both files use the same format.

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/61ca9e13ba8246ac. Report an issue: GitHub.