{"record":{"id":"c76bec3137ec95eb","repo":"anomalyco/sst","slug":"the-base-value-in-vite-config-ts-must-end-with-a","errorCode":null,"errorMessage":"The \"base\" value in vite.config.ts must end with a trailing slash (\"/\"). This is required for correct asset path construction.","messagePattern":"The \"base\" value in vite\\.config\\.ts must end with a trailing slash \\(\"/\"\\)\\. This is required for correct asset path construction\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/react.ts","lineNumber":435,"sourceCode":"          const content = fs.readFileSync(viteConfig, \"utf-8\");\n          const match = content.match(/[\"']?base[\"']?:\\s*[\"']([^\"]+)[\"']/);\n          return match ? match[1] : undefined;\n        } catch (e) { }\n      })();\n\n      // Get base configured in react-router config ie. \"/docs/\"\n      const reactRouterBase = (() => {\n        try {\n          const rrConfig = path.join(outputPath, \"react-router.config.ts\");\n          const content = fs.readFileSync(rrConfig, \"utf-8\");\n          const match = content.match(/[\"']?basename[\"']?:\\s*[\"']([^\"]+)[\"']/);\n          return match ? match[1] : undefined;\n        } catch (e) { }\n      })();\n\n      if (viteBase) {\n        if (!viteBase.endsWith(\"/\"))\n          throw new Error(\n            `The \"base\" value in vite.config.ts must end with a trailing slash (\"/\"). This is required for correct asset path construction.`,\n          );\n        if (!reactRouterBase)\n          throw new Error(\n            `Found \"base\" configured in vite.config.ts but missing \"basename\" in react-router.config.ts. Both configurations are required.`,\n          );\n      }\n      if (reactRouterBase) {\n        if (reactRouterBase.endsWith(\"/\"))\n          throw new Error(\n            `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.`,\n          );\n        if (!viteBase)\n          throw new Error(\n            `Found \"basename\" configured in react-router.config.ts but missing \"base\" in vite.config.ts. Both configurations are required.`,\n          );\n      }\n","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/react.ts#L417-L453","documentation":"In buildPlan, the React component reads the `base` value from vite.config.ts and requires it to end with a trailing slash so generated asset URLs are correct. A base without a trailing slash throws this plain Error.","triggerScenarios":"Setting base in vite.config.ts to a value like \"/app\" or \"https://cdn.example.com/app\" (no trailing slash) while deploying the React component.","commonSituations":"Vite accepts both forms locally, so the app works in `vite dev` but fails on SST deploy; teams moving from CRA or custom CDN paths.","solutions":["Append a trailing slash to the base value in vite.config.ts","Ensure react-router.config.ts defines a matching basename","Re-run sst deploy after the config change"],"exampleFix":"// vite.config.ts before\nexport default { base: \"/app\" };\n// after\nexport default { base: \"/app/\" };","handlingStrategy":"validation","validationCode":"const base = viteConfig.base;\nif (base && !base.endsWith(\"/\")) throw new Error(`vite base must end with '/': ${base}`);","typeGuard":null,"tryCatchPattern":"try {\n  new sst.aws.React(\"Web\", args);\n} catch (e) {\n  if (String(e).includes(\"trailing slash\")) console.error(\"Fix vite.config.ts base to end with '/'\");\n  throw e;\n}","preventionTips":["Always end vite base with a trailing slash (\"/app/\")","Keep vite base and react-router basename in sync","Run a local build (vite build) to catch config issues early"],"tags":["vite","react","asset-paths","configuration"],"backgroundTag":"config-validation-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}