diff --git a/packages/next/server/api-utils.ts b/packages/next/server/api-utils.ts index d82d9d6ea5378..e172995568f94 100644 --- a/packages/next/server/api-utils.ts +++ b/packages/next/server/api-utils.ts @@ -237,7 +237,7 @@ export function redirect( ) } res.writeHead(statusOrUrl, { Location: url }) - res.write('') + res.write(url) res.end() return res } diff --git a/test/integration/api-support/test/index.test.js b/test/integration/api-support/test/index.test.js index 93b18fb91014e..05a960be3a2f7 100644 --- a/test/integration/api-support/test/index.test.js +++ b/test/integration/api-support/test/index.test.js @@ -262,6 +262,8 @@ function runTests(dev = false) { }) expect(res.status).toEqual(307) + const text = await res.text() + expect(text).toEqual('/login') }) it('should redirect to login', async () => { @@ -277,6 +279,8 @@ function runTests(dev = false) { }) expect(res.status).toEqual(301) + const text = await res.text() + expect(text).toEqual('/login') }) it('should return empty query object', async () => {