Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.

Commit 00d3007

Browse files
committed
fix: page chunk for root level catch-all is served incorrectly to client
1 parent ed3b50f commit 00d3007

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

lib/steps/setupRedirects.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ const setupRedirects = () => {
5050
});
5151
});
5252

53+
// This redirect takes care of this issue: https://github.com/netlify/next-on-netlify/issues/43
54+
// where the page chunk for a root level catch-all is served incorrectly to the client.
55+
// Add last because it's least specific.
56+
if (nextRedirects.length >= 1)
57+
redirects.push("/_next/* /_next/static/* 200");
58+
5359
// Write redirects to _redirects file
5460
writeFileSync(join(NETLIFY_PUBLISH_PATH, "_redirects"), redirects.join("\n"));
5561
};

tests/__snapshots__/defaults.test.js.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ exports[`Routing creates Netlify redirects 1`] = `
2828
/getStaticProps/withRevalidate/withFallback/:id /.netlify/functions/next_getStaticProps_withRevalidate_withFallback_id 200
2929
/shows/:id /.netlify/functions/next_shows_id 200
3030
/shows/:params/* /.netlify/functions/next_shows_params 200
31-
/static/:id /static/[id].html 200"
31+
/static/:id /static/[id].html 200
32+
/_next/* /_next/static/* 200"
3233
`;

tests/__snapshots__/optionalCatchAll.test.js.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ exports[`Routing creates Netlify redirects 1`] = `
77
/_next/data/%BUILD_ID%/* /.netlify/functions/next_all 200
88
/page /.netlify/functions/next_page 200
99
/ /.netlify/functions/next_all 200
10-
/* /.netlify/functions/next_all 200"
10+
/* /.netlify/functions/next_all 200
11+
/_next/* /_next/static/* 200"
1112
`;

tests/getServerSidePropsIndexPage.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ describe("Routing", () => {
5656
expect(redirects[2]).toEqual(
5757
"/_next/data/%BUILD_ID%/index.json /.netlify/functions/next_index 200"
5858
);
59+
expect(redirects[3]).toEqual("/_next/* /_next/static/* 200");
5960

6061
// Check that no other redirects are present
61-
expect(redirects).toHaveLength(3);
62+
expect(redirects).toHaveLength(4);
6263
});
6364
});

0 commit comments

Comments
 (0)