-
Notifications
You must be signed in to change notification settings - Fork 88
fix: support non-prerendered dynamic routes with fallback false #1541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
61fe286
fix: bypass handler function for non-prerendered dynamic routes with …
orinokai b7a6872
fix: remove catch all handler redirect to support fallback false and …
orinokai b8e1950
feat: support custom 404 pages in all locales
orinokai 0996adc
feat: add custom 404 handling for static routes
orinokai 52ee02c
chore: refactor hidden path redirects
orinokai 18c2333
feat: add support for isr 404 pages
orinokai 8a361ae
feat: swap cache patch for forced manual revalidate
orinokai 2073b27
chore: add docs for patches
orinokai 046d375
feat: use revalidate header instead of server patch
orinokai 69a4146
test: add dynamic routing and fallback tests
orinokai 2b67d08
chore: fix eslint error
orinokai 39d6ea9
fix: remove fallback: true handling until runtime fix lands
orinokai 3f5e675
test: update tests while fallback:true works like fallback:blocking
orinokai 5806400
test: fix jest tests
orinokai 81d2d80
test: simplify cypress test names
orinokai bc0aace
Merge branch 'main' into rs/fallback-false-fix
orinokai 94e732c
fix: revert header revalidation owing to side-effects
orinokai 7a662ee
feat: patch next server to force revalidation only during cache fetches
orinokai dc424b3
test: update tests with new env var name
orinokai 68461db
Merge branch 'main' into rs/fallback-false-fix
orinokai eec91b0
test: update test with reverted handler signature
orinokai f81b2c3
Merge branch 'rs/fallback-false-fix' of github.com:netlify/netlify-pl…
orinokai 8732a49
fix: reinstate catch-all redirect for Next redirect handling
orinokai 636d887
Merge branch 'main' into rs/fallback-false-fix
orinokai e056209
test: update snapshot with new redirects
orinokai 987defd
test: update cypress tests for correct render mode
orinokai 4f41b49
Merge branch 'rs/fallback-false-fix' of github.com:netlify/netlify-pl…
orinokai f77d276
Merge branch 'main' into rs/fallback-false-fix
orinokai 55de50a
Merge branch 'main' into rs/fallback-false-fix
orinokai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,127 @@ | ||
describe('Static Routing', () => { | ||
it('renders correct page via SSR on a static route', () => { | ||
cy.request('/getServerSideProps/static/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'ssr') | ||
expect(res.body).to.contain('Sleepy Hollow') | ||
}) | ||
}) | ||
it('serves correct static file on a static route', () => { | ||
cy.request('/getStaticProps/static/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-render-mode') | ||
expect(res.body).to.contain('Dancing with the Stars') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a static route', () => { | ||
cy.request('/getStaticProps/with-revalidate/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.body).to.contain('Dancing with the Stars') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Dynamic Routing', () => { | ||
it('loads page', () => { | ||
cy.visit('/shows/250') | ||
cy.findByRole('heading').should('contain', '250') | ||
cy.findByText('Kirby Buckets') | ||
it('renders correct page via SSR on a dynamic route', () => { | ||
cy.request('/getServerSideProps/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'ssr') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders correct page via SSR on a dynamic catch-all route', () => { | ||
cy.request('/getServerSideProps/all/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'ssr') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('serves correct static file on a prerendered dynamic route with fallback: false', () => { | ||
cy.request('/getStaticProps/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-render-mode') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders custom 404 on a non-prerendered dynamic route with fallback: false', () => { | ||
cy.request({ url: '/getStaticProps/3/', failOnStatusCode: false }).then((res) => { | ||
expect(res.status).to.eq(404) | ||
expect(res.headers).to.have.property('x-render-mode', 'odb') | ||
expect(res.body).to.contain('Custom 404') | ||
}) | ||
}) | ||
it('serves correct static file on a prerendered dynamic route with fallback: true', () => { | ||
cy.request('/getStaticProps/withFallback/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-render-mode') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders fallback page via ODB on a non-prerendered dynamic route with fallback: true', () => { | ||
cy.request('/getStaticProps/withFallback/3/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
// expect 'odb' until https://github.com/netlify/pillar-runtime/issues/438 is fixed | ||
expect(res.headers).to.have.property('x-render-mode', 'odb') | ||
// expect 'Bitten' until the above is fixed and we can test for fallback 'Loading...' message | ||
expect(res.body).to.contain('Bitten') | ||
}) | ||
}) | ||
it('serves correct static file on a prerendered dynamic route with fallback: blocking', () => { | ||
cy.request('/getStaticProps/withFallbackBlocking/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.not.have.property('x-render-mode') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a non-prerendered dynamic route with fallback: blocking', () => { | ||
cy.request('/getStaticProps/withFallbackBlocking/3/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'odb') | ||
expect(res.body).to.contain('Bitten') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: false', () => { | ||
cy.request('/getStaticProps/withRevalidate/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders custom 404 on a non-prerendered dynamic route with revalidate and fallback: false', () => { | ||
cy.request({ url: '/getStaticProps/withRevalidate/3/', failOnStatusCode: false }).then((res) => { | ||
expect(res.status).to.eq(404) | ||
expect(res.headers).to.have.property('x-render-mode', 'odb') | ||
expect(res.body).to.contain('Custom 404') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: true', () => { | ||
cy.request('/getStaticProps/withRevalidate/withFallback/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders fallback page via ODB on a non-prerendered dynamic route with revalidate and fallback: true', () => { | ||
cy.request('/getStaticProps/withRevalidate/withFallback/3/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
// expect 'Bitten' until https://github.com/netlify/pillar-runtime/issues/438 is fixed | ||
expect(res.body).to.contain('Bitten') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a prerendered dynamic route with revalidate and fallback: blocking', () => { | ||
cy.request('/getStaticProps/withRevalidate/withFallbackBlocking/1/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.body).to.contain('Under the Dome') | ||
}) | ||
}) | ||
it('renders correct page via ODB on a non-prerendered dynamic route with revalidate and fallback: blocking', () => { | ||
cy.request('/getStaticProps/withRevalidate/withFallbackBlocking/3/').then((res) => { | ||
expect(res.status).to.eq(200) | ||
expect(res.headers).to.have.property('x-render-mode', 'isr') | ||
expect(res.body).to.contain('Bitten') | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.