Skip to content

fix(vite): Skip SSR middleware in preview server for SPA mode#14673

Merged
jacob-ebey merged 5 commits intoremix-run:devfrom
andreiborza:ab/fix-ssr-vite-preview
Dec 18, 2025
Merged

fix(vite): Skip SSR middleware in preview server for SPA mode#14673
jacob-ebey merged 5 commits intoremix-run:devfrom
andreiborza:ab/fix-ssr-vite-preview

Conversation

@andreiborza
Copy link
Contributor

@andreiborza andreiborza commented Dec 18, 2025

When ssr: false is configured, the build removes the server bundle but configurePreviewServer was attempting to import it, causing "Cannot find module" errors when using vite preview.

Now skips SSR handling when SSR is disabled, allowing vite preview to work correctly in SPA mode.

Closes: #14672


Test demonstrating the issue: 8724df0
Fix for the issue: 37189ba

@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

🦋 Changeset detected

Latest commit: cb861b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@react-router/dev Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch
react-router Patch
react-router-dom Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Dec 18, 2025

Hi @andreiborza,

Welcome, and thank you for contributing to React Router!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Dec 18, 2025

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@andreiborza andreiborza force-pushed the ab/fix-ssr-vite-preview branch 2 times, most recently from 976d286 to 1053d8d Compare December 18, 2025 09:40
When `ssr: false` is configured, the build removes the server bundle but `configurePreviewServer` was attempting to import it, causing "Cannot find module" errors when using `vite preview`.

Now skips SSR handling when SSR is disabled, allowing `vite preview` to work correctly in SPA mode.

Closes: remix-run#14672
@andreiborza andreiborza changed the base branch from main to dev December 18, 2025 09:49
@andreiborza andreiborza force-pushed the ab/fix-ssr-vite-preview branch from 1053d8d to 37189ba Compare December 18, 2025 09:50
@jacob-ebey jacob-ebey merged commit 915694e into remix-run:dev Dec 18, 2025
11 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

🤖 Hello there,

We just published version 7.12.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

🤖 Hello there,

We just published version 7.12.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot find module build/server/index.js in SPA mode with vite preview since 7.11.0

3 participants