diff --git a/.changeset/fix-spa-vite-preview.md b/.changeset/fix-spa-vite-preview.md new file mode 100644 index 0000000000..23c077eec1 --- /dev/null +++ b/.changeset/fix-spa-vite-preview.md @@ -0,0 +1,5 @@ +--- +"@react-router/dev": patch +--- + +fix(vite): Skip SSR middleware in preview server for SPA mode diff --git a/contributors.yml b/contributors.yml index ff24ac4b77..e8a8cd30dd 100644 --- a/contributors.yml +++ b/contributors.yml @@ -29,6 +29,7 @@ - amsal - Andarist - andreasottosson-polestar +- andreiborza - andreiduca - antonmontrezor - appden diff --git a/integration/vite-preview-test.ts b/integration/vite-preview-test.ts index 65eb1611fe..bdf23eecf8 100644 --- a/integration/vite-preview-test.ts +++ b/integration/vite-preview-test.ts @@ -314,4 +314,74 @@ test.describe("Vite preview", () => { "Product 123", ); }); + + test("serves SPA mode app with vite preview", async ({ + vitePreview, + page, + }) => { + const files: Files = async ({ port }) => ({ + "react-router.config.ts": reactRouterConfig({ + ssr: false, + v8_viteEnvironmentApi: true, + }), + "vite.config.ts": await viteConfig.basic({ + port, + templateName: "vite-6-template", + }), + "app/root.tsx": tsx` + import { Links, Meta, Outlet, Scripts } from "react-router"; + + export default function Root() { + return ( + +
+ +SPA Mode Enabled
+About page in SPA mode
+