Skip to content

Commit 869aab3

Browse files
IgnisDaijjk
andauthored
fix standalone wrong url being logged (#44887)
Co-authored-by: JJ Kasper <[email protected]>
1 parent 969cca8 commit 869aab3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/next/src/build/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ server.listen(currentPort, (err) => {
17891789
console.log(
17901790
'Listening on port',
17911791
currentPort,
1792-
'url: http://localhost:' + currentPort
1792+
'url: http://' + hostname + ':' + currentPort
17931793
)
17941794
})`
17951795
)

test/production/standalone-mode/response-cache/index.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('minimal-mode-response-cache', () => {
1515
let next: NextInstance
1616
let server
1717
let appPort
18+
let output = ''
1819

1920
beforeAll(async () => {
2021
// test build against environment with next support
@@ -59,11 +60,18 @@ describe('minimal-mode-response-cache', () => {
5960
/Listening on/,
6061
{
6162
...process.env,
63+
HOSTNAME: '',
6264
PORT: appPort,
6365
},
6466
undefined,
6567
{
6668
cwd: next.testDir,
69+
onStdout(msg) {
70+
output += msg
71+
},
72+
onStderr(msg) {
73+
output += msg
74+
},
6775
}
6876
)
6977
})
@@ -72,6 +80,11 @@ describe('minimal-mode-response-cache', () => {
7280
if (server) await killApp(server)
7381
})
7482

83+
it('should have correct "Listening on" log', async () => {
84+
expect(output).toContain(`Listening on port`)
85+
expect(output).toContain(`url: http://localhost:${appPort}`)
86+
})
87+
7588
it('should have correct responses', async () => {
7689
const html = await renderViaHTTP(appPort, '/')
7790
expect(html.length).toBeTruthy()

0 commit comments

Comments
 (0)