Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix standalone not found" #51506

Merged
merged 1 commit into from Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/next/src/build/utils.ts
Expand Up @@ -1928,21 +1928,20 @@ export async function copyTracedFiles(
serverOutputPath,
`${
moduleType
? `\
import http from 'http'
? `import http from 'http'
import path from 'path'
import { fileURLToPath } from 'url'
import { createServerHandler } from 'next/dist/server/lib/render-server-standalone.js'

const __dirname = fileURLToPath(new URL('.', import.meta.url))
import { createServerHandler } from 'next/dist/server/lib/render-server-standalone.js'
`
: `\
: `
const http = require('http')
const path = require('path')
const { createServerHandler } = require('next/dist/server/lib/render-server-standalone')`
}

const dir = path.join(__dirname)

process.env.NODE_ENV = 'production'
process.chdir(__dirname)

Expand All @@ -1963,7 +1962,6 @@ const nextConfig = ${JSON.stringify({

process.env.__NEXT_PRIVATE_STANDALONE_CONFIG = JSON.stringify(nextConfig)


createServerHandler({
port: currentPort,
hostname,
Expand Down
11 changes: 3 additions & 8 deletions packages/next/src/server/lib/render-server-standalone.ts
Expand Up @@ -5,6 +5,8 @@ import httpProxy from 'next/dist/compiled/http-proxy'
import { Worker } from 'next/dist/compiled/jest-worker'
import { normalizeRepeatedSlashes } from '../../shared/lib/utils'

const renderServerPath = require.resolve('./render-server')

export const createServerHandler = async ({
port,
hostname,
Expand All @@ -18,20 +20,13 @@ export const createServerHandler = async ({
dev?: boolean
minimalMode: boolean
}) => {
const nextConfig = JSON.parse(
process.env.__NEXT_PRIVATE_STANDALONE_CONFIG || '{}'
)
const routerWorker = new Worker(require.resolve('./render-server'), {
const routerWorker = new Worker(renderServerPath, {
numWorkers: 1,
maxRetries: 10,
forkOptions: {
env: {
FORCE_COLOR: '1',
...process.env,
__NEXT_PRIVATE_PREBUNDLED_REACT: nextConfig?.experimental
?.useServerActions
? 'experimental'
: 'next',
},
},
exposedMethods: ['initialize'],
Expand Down
3 changes: 0 additions & 3 deletions test/e2e/app-dir/app/app/dashboard/not-found.js

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -127,12 +127,4 @@ describe('should set-up next', () => {
expect(res.headers.get('x-next-cache-tags')).toBeFalsy()
}
})

it('should handle correctly not-found.js', async () => {
const res = await fetchViaHTTP(appPort, '/not-found/does-not-exist')
expect(res.status).toBe(404)
const html = await res.text()
expect(html).toContain('not-found-page-404')
expect(html).not.toContain('not-found-page-200')
})
})