From 21d7734ba3b3ff5e65168a17d8e1303dce718544 Mon Sep 17 00:00:00 2001 From: Kensuke Takahara Date: Sat, 12 Mar 2022 14:55:09 +0900 Subject: [PATCH 1/2] add content-type to header in redirectByPageProps. --- packages/libs/core/src/handle/redirect.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/libs/core/src/handle/redirect.ts b/packages/libs/core/src/handle/redirect.ts index 0a8f1aae63..ceb323330d 100644 --- a/packages/libs/core/src/handle/redirect.ts +++ b/packages/libs/core/src/handle/redirect.ts @@ -13,6 +13,7 @@ export const redirectByPageProps = (event: Event, route: RedirectRoute) => { "cache-control", route.headers?.cacheControl?.join(":") ?? "" ); + event.res.setHeader("Content-Type", "application/json"); event.res.statusCode = 200; const body = { From 31e1534211b8a9f09221dfebae55e647ee9b58ad Mon Sep 17 00:00:00 2001 From: Kensuke Takahara Date: Sat, 12 Mar 2022 14:55:48 +0900 Subject: [PATCH 2/2] fix e2e test code. --- .../integration/static-regeneration.test.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/e2e-tests/next-app-with-locales/cypress/integration/static-regeneration.test.ts b/packages/e2e-tests/next-app-with-locales/cypress/integration/static-regeneration.test.ts index c33f7b9ce9..2e73bb2277 100644 --- a/packages/e2e-tests/next-app-with-locales/cypress/integration/static-regeneration.test.ts +++ b/packages/e2e-tests/next-app-with-locales/cypress/integration/static-regeneration.test.ts @@ -5,12 +5,19 @@ describe("ISR Tests", () => { describe("SSG Redirect", () => { it("non existing user redirects to home", () => { const path = "/en/revalidated-ssg-pages/106"; - cy.ensureRouteHasStatusCode(path, 307); + cy.request({ url: path }).then((response) => { + expect(response.status).to.equal(200); - const redirectedPath = "/"; - - // Verify redirect response - cy.verifyRedirect(path, redirectedPath, 307); + const redirectedPath = "/"; + // Verify redirect response + expect(response.body).to.deep.equal({ + pageProps: { + __N_REDIRECT: redirectedPath, + __N_REDIRECT_STATUS: 307 + }, + __N_SSG: true + }); + }); }); }); describe("SSG page", () => {