Skip to content

fix: correctly rewrite default locale ISR homepage to ODB handler #1757

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

Closed
wants to merge 31 commits into from

Conversation

orinokai
Copy link
Contributor

Summary

ISR homepages with i18n were not correctly matched as static routes and were being served as SSR pages because no rewrite was created. This was because the matcher only worked for URLs with subpaths.

This PR updates the logic to match URLs prefixed with the default locale, with or without a subpath, and ensures that, when slicing off the locale, an index page at the root defaults to '/'.

Test plan

Snapshots have been updated with the new redirects. Tests should pass as before.

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Fixes netlify/pod-ecosystem-frameworks#233

@orinokai orinokai requested a review from a team November 10, 2022 11:26
@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/63b58f09018e530008910d37
😎 Deploy Preview https://deploy-preview-1757--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/63b58f0979c0750008fb538c
😎 Deploy Preview https://deploy-preview-1757--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@orinokai orinokai added the type: bug code to address defects in shipped code label Nov 10, 2022
@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/63b58f09018e530008910d3c
😎 Deploy Preview https://deploy-preview-1757--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/63b58f099090ee00098a3ff5
😎 Deploy Preview https://deploy-preview-1757--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/63b58f0979c0750008fb5389
😎 Deploy Preview https://deploy-preview-1757--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/63b58f09075f5b00079d37fa
😎 Deploy Preview https://deploy-preview-1757--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/63b58f09166d5d00084f0272
😎 Deploy Preview https://deploy-preview-1757--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/63b58f09316d640008d2e444
😎 Deploy Preview https://deploy-preview-1757--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit 532d38d
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/63b58f098cb18d000b6ad21a
😎 Deploy Preview https://deploy-preview-1757--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@orinokai orinokai marked this pull request as draft November 11, 2022 17:46
@netlify
Copy link

netlify bot commented Nov 18, 2022

Deploy Preview for nextjs-plugin-next-11-demo failed.

Name Link
🔨 Latest commit 6bdee93
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-next-11-demo/deploys/6377b4da1c657b00098e8415

@orinokai orinokai marked this pull request as ready for review December 5, 2022 14:50
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@ascorbic
Copy link
Contributor

ascorbic commented Dec 8, 2022

I think CodeQL's complaints could be fixed by casting the value with Number()

…ck (#1795)

* fix: rewrite fallback false routes to 404 page

* fix: allow ISR 404 pages to use the ODB handler

* chore: update tests to expect static 404 pages for fallback false

* chore: fix boolean type on is404Isr param

* chore: add tests for 404 redirects
@orinokai
Copy link
Contributor Author

orinokai commented Dec 9, 2022

@ascorbic the new proxy API validates that this is a number anyway, so I think it's fine to just ignore CodeQL in this case

@orinokai orinokai marked this pull request as draft December 9, 2022 12:47
renovate bot and others added 2 commits December 12, 2022 02:19
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
* chore: update canary demo

* chore: add app-dir demo

* fix: resolve page deps in app dir

* fix: patch duplicate declaration

* fix: resolve nft deps

* feat: add support for appdir edge runtime

* chore: update next canary and react (and change APIs)

* fix: update patch syntax

* fix: include file itself in deps

* chore: upgrade next and remove workaround

* chore: move app-dir site to canary

* chore: update snapshot

* chore: add initial app-dir tests

* chore: use correct site for canary tests

* chore: enable plugin

* ci: use vitest for canary e2e tests

* chore: re-enable plugin

* chore: setup playwright

* chore: wait longer when first using playwright

* chore: run tests headless

* chore: install chromium

* chore: longer timeout

* chore: use undici

* chore: enable remaining tests

* chore: fix test syntax

* chore: update demos

* chore: update canary

* chore: fix 404 test

* chore: disable test that depends on an upstream fix

* chore: fix handling of "self" object

* chore: update packages

* chore: update canary

* chore: tidy and add license for next.js code

* chore: handle empty static manifest

* chore: downgrasde canary because of regression

* chore: logging for windows

* Apply suggestions from code review

Co-authored-by: Erica Pisani <[email protected]>

* chore: update next canary

* chore: remove npmrc

* chore: update next and react

* chore: update test site

* chore: update tests

* chore: add back npmrc
This reverts commit 40480f4.

* fix: use globby not tiny-glob

* chore: update fixtures

* chore: deps

* chore: update tests and demo

* fix: correct request types

* fix: skip generating lambda for edge api routes

* chore: log request

* chore: add runtime as dep

* chore: pre-version

* chore: add canary to ws

* chore: fix build

* chore: fix monorepo setup

* chore: upgrade

* chore: react no-longer pre-bundled

* chore: remove deliberately broken demo pages

* fix: move pre-rendered appdir files

* fix: correct manifest path

* chore: update demo

* chore: update tests

* chore: add sass test

* chore: update demo config

* chore: skip test that also fails upstream

* chore: update next canary

* chore: update use usage

* chore: update canary

* fix: support loading static files for both pages and app

* chore: update canary

* chore: update canary

* chore: final canary!

* chore(deps): update demos and deps to Next 13

* chore: add swc

* chore: switch old node tests to use node 14

* fix: correct requestdata type

* chore: update next/link syntax

* chore: use legacy image component for now

* chore: update demo

* chore: update canary demo

* chore: all the tests

* chore: fix eslint

* chore: parallelise e2e tests

* chore: don't fail fast

* chore: unignore modules and use node-fetch

* chore: very parallel

* chore: don't mock fetch 🤦

* chore: remove disabled tests

* chore: test with node 18

* chore: switchable fetch

* chore: remove irrelevant tests

* chore: remove disabled test

* chore: add reporter

* chore: no concurrency

* chore: try to fix jest

* chore: fix test command

* chore: artifact file path

* chore: use site build command

* chore: download artifacts

* chore: report per-chunk

* chore: update syntax

* chore: report to summary

* chore: do annotate

* chore: update and add summary

* chore: rearrange

* chore: combine tests

* chore: fix test

* chore: rearrange and disable failing suites

* chore: skip broken ntl and fail faster

* chore: disable suite

* chore: skip failing tests

* chore: add ability to run disabled tests

* chore: add comments to workflow file

* chore: one worker per file

* chore: oops

* chore: make path relative to test dir

* chore: conditionally skip

* chore: enable middleware-responses test

* chore: run all tests once

* chore: don't run disabled tests

* fix: ensure responses are Responses

* chore: re-enable test

* chore: run all tests

* chore: enable another suite

* fix: better headers.getAll polyfill

* chore: enable middleware-redirects suite

* chore: conditionally enable req body tests

* chore: disable failing tests

* chore: add test readme doc

* chore: remove eslint changes

* chore: add new appdir tests

* chore: use canary for appdir tests

* chore: use extended matchers

* chore: increase timeout

* chore: enable tests that were disabled upstream

* chore: don't clobber package.json in tests

* chore: set EdgeRuntime name globally

* chore: remove logs

* chore: update tests

* chore: test updates

* chore: increase timeout

* chore: increase timeout for site deploy

* chore: include step annotations

* chore: don't use canary demo for this

* chore: increase timeout

* chore: add rewrite-to-edge demo

* chore: deploy edge functions after cache

* chore: refresh lockfile

* chore: enable rewrite tests

* chore: update tests

* chore: update tests

* chore: enable rsc tests

* chore: skip tests

* chore: re-enable dev check

* chore: update lockfile

* chore: run workflows only on new pr and pr sync

* chore: add log about testing appdir

* chore: only use cache: manual if site uses appDir

* chore: changes from review

* ci: fix e2e test

* fix: correctly match static files against rewrites

* chore: upgrade next

* chore: increase timeout

* chore: extend timeout

* fix: handle prefetch correctly

* chore: rmeove log

* chore: log env

* chore: enough with these rules

* chore: fix base url

* chore: try with all tests

* chore: don't run disabled tests

* fix: vary on prefetch

Co-authored-by: Erica Pisani <[email protected]>
renovate bot and others added 19 commits December 16, 2022 15:59
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: token-generator-app[bot] <82042599+token-generator-app[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* fix: serve static files from basePath

* chore: add test

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
* chore: update next to 13.0.7

* chore: disable test

Co-authored-by: Matt Kane <[email protected]>
Co-authored-by: Matt Kane <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@orinokai
Copy link
Contributor Author

orinokai commented Jan 5, 2023

Closing in favour of #1867 which is a more tidy version with the TV Maze API Proxy stuff split into a separate PR

@orinokai orinokai closed this Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants