From dcdededa5e6399a658ba2aee81c5520e798c309d Mon Sep 17 00:00:00 2001 From: Michiel Van Gendt Date: Wed, 19 May 2021 12:38:57 +0200 Subject: [PATCH 1/2] Include message body in redirect responses --- packages/next/next-server/server/api-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/next-server/server/api-utils.ts b/packages/next/next-server/server/api-utils.ts index 350a87dac212f..933b1b55218e6 100644 --- a/packages/next/next-server/server/api-utils.ts +++ b/packages/next/next-server/server/api-utils.ts @@ -217,7 +217,7 @@ export function redirect( ) } res.writeHead(statusOrUrl, { Location: url }) - res.write('') + res.write(url) res.end() return res } From 88deb8322062afb1dd56d459064da34732e6ffd3 Mon Sep 17 00:00:00 2001 From: Michiel Van Gendt Date: Sat, 29 May 2021 15:10:04 +0200 Subject: [PATCH 2/2] Add iontegration tests for redirect fix --- test/integration/api-support/test/index.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/integration/api-support/test/index.test.js b/test/integration/api-support/test/index.test.js index 1b7972ff9c875..a5cb8eb7a9a5e 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 () => {