Skip to content

Setting Vite Environment API future flag in react-router config prevents react-router server handler from being generated #698

@jimmend

Description

@jimmend

Describe the bug
The plugin does not currently support the Vite Environment API build model. So, when the future flag for the Vite Environment API build model is set to "true" the site does not properly deploy on netlify.

To Reproduce

  1. Go to the site's react-router.config.ts file.
  2. Set the config's future >> v8_viteEnvironmentApi value to true. For example:
{
...
  future: {
    v8_viteEnvironmentApi: true,
  }
  1. Deploy the site to Netlify.
  2. Navigate to the site.
  3. The site will throw a 404 error because the react-router server handler function is not build during deployment.

Expected behavior

During deployment, the react-router server handler function should be created.

Desktop (please complete the following information):

  • OS: Windows
  • Browser chrome
  • Version 148.0.7778.97

Additional context
Per Copilot, the issue occurs because the flag changes how Vite runs the SSR build from the old "isSsrBuild" model to the new Environment API model. The Netlify plugin checks isSsrBuild === true to know it should inject its server.js entry point, so that check is never triggered under the new model.

It seems this will definitly need to be addressed before react-router moves to version 8. Currently, the workaround is to set the v8_viteEnvironmentApi flag to false, which will not be possible in v8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions