Skip to content
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

Fix: Legacy fallback env var #2074

Merged
merged 23 commits into from May 5, 2023
Merged

Fix: Legacy fallback env var #2074

merged 23 commits into from May 5, 2023

Conversation

taty2010
Copy link
Contributor

@taty2010 taty2010 commented Apr 27, 2023

Summary

This PR allows users to opt-in to the legacy behavior for dynamic routes set to fallback:false by adding the env var LEGACY_FALLBACK_FALSE='true'. When hitting a non-existent path on a dynamic route, it will hit the origin server which will give users the ability to add redirects for those paths.

closes https://github.com/netlify/pod-ecosystem-frameworks/issues/446

Test plan

  1. add env var LEGACY_FALLBACK_FALSE='true'
  2. ntl serve
  3. When checking Network tab within dev tools you should see header x-nf-render-mode:odb

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

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@netlify
Copy link

netlify bot commented Apr 27, 2023

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

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/6454f43c62801000080fb552
😎 Deploy Preview https://deploy-preview-2074--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.

@netlify
Copy link

netlify bot commented Apr 27, 2023

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

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/6454f43c89def20008ed34a7
😎 Deploy Preview https://deploy-preview-2074--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.

@taty2010 taty2010 changed the title Tn/legacy fallback env var Fix: Legacy fallback env var Apr 27, 2023
@github-actions github-actions bot added the type: bug code to address defects in shipped code label Apr 27, 2023
@netlify
Copy link

netlify bot commented Apr 27, 2023

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

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/6454f43cd1e46200089495c2
😎 Deploy Preview https://deploy-preview-2074--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 Apr 27, 2023

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

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/6454f43cc653250008dbb651
😎 Deploy Preview https://deploy-preview-2074--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 Apr 27, 2023

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

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/6454f43ce49cd90008713e46
😎 Deploy Preview https://deploy-preview-2074--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 Apr 27, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/6454f43c0b499d00083ea331
😎 Deploy Preview https://deploy-preview-2074--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 Apr 27, 2023

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

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/6454f43ccd6efa0008cd5891
😎 Deploy Preview https://deploy-preview-2074--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 Apr 27, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/6454f43cfa228c0008ca290b
😎 Deploy Preview https://deploy-preview-2074--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 Apr 27, 2023

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

Name Link
🔨 Latest commit 7a7b579
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/6454f43c727cc70008f3093b
😎 Deploy Preview https://deploy-preview-2074--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.

@taty2010 taty2010 marked this pull request as ready for review April 29, 2023 03:07
@taty2010 taty2010 requested a review from a team April 29, 2023 03:07
},
]

const middleware = await getMiddleware(path.resolve('.next'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the middleware affect the tests in any way? If so consider tests with and without it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if we wanted to test the matchesMiddleware functionality then it would matter. For these tests, we can just set the middleware to default to an empty array so that we can reach the logic we need to test related to the env var.

test/helpers/utils.spec.ts Outdated Show resolved Hide resolved
@taty2010 taty2010 self-assigned this May 2, 2023
} else if (
prerenderedDynamicRoutes[route.page].fallback === false &&
!is404Isr &&
!process.env.LEGACY_FALLBACK_FALSE
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work if folks use LEGACY_FALLBACK_FALSE = 'false' so we need to test for strings too. In other areas of the Runtime we've used destr so I'd suggest that as a convention: https://github.com/netlify/next-runtime/blob/split-api-routes/packages/runtime/src/index.ts#L106

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up Rob and the ref code.

test/helpers/utils.spec.ts Outdated Show resolved Hide resolved
test/helpers/utils.spec.ts Outdated Show resolved Hide resolved
taty2010 and others added 3 commits May 3, 2023 22:38
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
@LekoArts
Copy link
Contributor

LekoArts commented May 4, 2023

Linting in unit tests isn't happy

@LekoArts LekoArts dismissed nickytonline’s stale review May 5, 2023 12:11

Changes were addressed

@LekoArts LekoArts merged commit aad9e5f into main May 5, 2023
100 of 101 checks passed
@LekoArts LekoArts deleted the tn/legacyFallbackEnvVar branch May 5, 2023 12:39
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.

None yet

4 participants