diff --git a/packages/next/src/build/utils.ts b/packages/next/src/build/utils.ts index 49c1f1da010fb..e13a8ff1c0133 100644 --- a/packages/next/src/build/utils.ts +++ b/packages/next/src/build/utils.ts @@ -1789,7 +1789,7 @@ server.listen(currentPort, (err) => { console.log( 'Listening on port', currentPort, - 'url: http://localhost:' + currentPort + 'url: http://' + hostname + ':' + currentPort ) })` ) diff --git a/test/production/standalone-mode/response-cache/index.test.ts b/test/production/standalone-mode/response-cache/index.test.ts index e311bfc8aaa4f..3674825a38511 100644 --- a/test/production/standalone-mode/response-cache/index.test.ts +++ b/test/production/standalone-mode/response-cache/index.test.ts @@ -15,6 +15,7 @@ describe('minimal-mode-response-cache', () => { let next: NextInstance let server let appPort + let output = '' beforeAll(async () => { // test build against environment with next support @@ -59,11 +60,18 @@ describe('minimal-mode-response-cache', () => { /Listening on/, { ...process.env, + HOSTNAME: '', PORT: appPort, }, undefined, { cwd: next.testDir, + onStdout(msg) { + output += msg + }, + onStderr(msg) { + output += msg + }, } ) }) @@ -72,6 +80,11 @@ describe('minimal-mode-response-cache', () => { if (server) await killApp(server) }) + it('should have correct "Listening on" log', async () => { + expect(output).toContain(`Listening on port`) + expect(output).toContain(`url: http://localhost:${appPort}`) + }) + it('should have correct responses', async () => { const html = await renderViaHTTP(appPort, '/') expect(html.length).toBeTruthy()