Fix React channel env missing in custom server (#49168)
Fixes #48948 ([repro](https://github.com/vercel/next.js/issues/48948#issuecomment-1533542001)). When running inside a custom server with app dir, we should always opt into the prebundled React with correct channels. Thanks @karlhorky for help testing it! Fixes #49169 too. --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
parent
39654fd4bb
commit
248f2defc2
3 changed files with 13 additions and 8 deletions
|
@ -285,8 +285,6 @@ export default async function build(
|
|||
const isAppDirEnabled = !!config.experimental.appDir
|
||||
|
||||
if (isAppDirEnabled) {
|
||||
process.env.NEXT_PREBUNDLED_REACT = '1'
|
||||
|
||||
if (!process.env.__NEXT_TEST_MODE && ciEnvironment.hasNextSupport) {
|
||||
const requireHook = require.resolve('../server/require-hook')
|
||||
const contents = await promises.readFile(requireHook, 'utf8')
|
||||
|
|
|
@ -178,9 +178,18 @@ export class NextServer {
|
|||
)
|
||||
}
|
||||
}
|
||||
if (conf.experimental.appDir) {
|
||||
process.env.NEXT_PREBUNDLED_REACT = '1'
|
||||
|
||||
if (this.options.customServer !== false) {
|
||||
// When running as a custom server with app dir, we must set this env
|
||||
// to correctly alias the React versions.
|
||||
if (conf.experimental.appDir) {
|
||||
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = conf.experimental
|
||||
.serverActions
|
||||
? 'experimental'
|
||||
: 'next'
|
||||
}
|
||||
}
|
||||
|
||||
this.server = await this.createServer({
|
||||
...this.options,
|
||||
conf,
|
||||
|
|
|
@ -7,7 +7,7 @@ createNextDescribe(
|
|||
{
|
||||
files: __dirname,
|
||||
},
|
||||
({ next, isNextDev, isNextDeploy }) => {
|
||||
({ next, isNextDeploy }) => {
|
||||
describe('query string', () => {
|
||||
it('should set query correctly', async () => {
|
||||
const browser = await webdriver(next.url, '/')
|
||||
|
@ -184,9 +184,7 @@ createNextDescribe(
|
|||
}
|
||||
|
||||
expect(stored).toEqual({
|
||||
// Not actually sure why this is '2' in dev. Possibly something
|
||||
// related to an update triggered by <HotReload>?
|
||||
'navigate-https://example.vercel.sh/': isNextDev ? '2' : '1',
|
||||
'navigate-https://example.vercel.sh/': '1',
|
||||
'navigation-supported': 'true',
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue