Skip to content

fix: correctly enable edge images #1631

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 6 commits into from
Oct 3, 2022
Merged

fix: correctly enable edge images #1631

merged 6 commits into from
Oct 3, 2022

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Sep 22, 2022

Summary

When we changed the logic so that EFs are used by default for middleware, we accidentally chnaged back the logic so that image content negotiation was no longer done with them by default. This PR fixes that, and EFs are used for image content negotiation unless disabled.

Fixes #1648

Test plan

  1. Visit the /image page in the default demo and ensure that the generated images are not redirected to /_ipx

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

emo capy

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.

@ascorbic ascorbic requested a review from a team September 22, 2022 11:20
@netlify
Copy link

netlify bot commented Sep 22, 2022

Deploy Preview for next-hp-edge-demo ready!

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/next-hp-edge-demo/deploys/633ada8033c3c1000971404e
😎 Deploy Preview https://deploy-preview-1631--next-hp-edge-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 Sep 22, 2022

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

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/633ada80512ce00009d65b1d
😎 Deploy Preview https://deploy-preview-1631--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 Sep 22, 2022

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

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/633ada8076d8880008d657c2
😎 Deploy Preview https://deploy-preview-1631--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.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Sep 22, 2022
@netlify
Copy link

netlify bot commented Sep 22, 2022

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

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/633ada800852a10008b88587
😎 Deploy Preview https://deploy-preview-1631--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 Sep 22, 2022

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

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/633ada807c8a2f000898de40
😎 Deploy Preview https://deploy-preview-1631--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.

@netlify
Copy link

netlify bot commented Sep 22, 2022

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

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/633ada807c8a2f000898de48
😎 Deploy Preview https://deploy-preview-1631--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 Sep 22, 2022

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/633ada80ebc5da0008148217
😎 Deploy Preview https://deploy-preview-1631--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 Sep 22, 2022

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

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/633ada803f74710008c0ec90
😎 Deploy Preview https://deploy-preview-1631--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 Sep 22, 2022

Deploy Preview for next-plugin-rsc-demo ready!

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-rsc-demo/deploys/633ada80ebc5da0008148212
😎 Deploy Preview https://deploy-preview-1631--next-plugin-rsc-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 Sep 22, 2022

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/633ada804eca32000a0564ee
😎 Deploy Preview https://deploy-preview-1631--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 Sep 22, 2022

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

Name Link
🔨 Latest commit 8a5a9c6
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/633ada80b40f4500092f3adb
😎 Deploy Preview https://deploy-preview-1631--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.

Copy link

@ericapisani ericapisani left a comment

Choose a reason for hiding this comment

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

These changes generally look good to me. Is it possible to get some of this under some sort of test coverage as well?

@ascorbic ascorbic requested a review from ericapisani October 3, 2022 12:03
ericapisani
ericapisani previously approved these changes Oct 3, 2022
process.env.NEXT_DISABLE_EDGE_IMAGES !== '1' &&
process.env.NEXT_DISABLE_EDGE_IMAGES !== 'true' &&
process.env.NEXT_DISABLE_NETLIFY_EDGE !== 'true' &&
process.env.NEXT_DISABLE_NETLIFY_EDGE !== '1'

Choose a reason for hiding this comment

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

[sand] It's a shame I wasn't able to get my IPX work in before these changes because I'm adding the isEnvSet method that we also have in the Gatsby plugin to help make logic like this a little easier on the eyes.

You're free to include the method in your PR if you'd like to use here and I can resolve the conflicts in my branch, but no worries if you're a bit pressed for time and would rather leave this as is for the time being.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ericapisani I've updated it to use destr

Choose a reason for hiding this comment

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

@ascorbic Would we rather use this going forward everywhere else? Can be done as a follow up, but we'd likely want to add it to the project board for someone to eventually pick up as an easy win if so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but bear in mind we can't use it inside the patched code

}

if (middlewareManifest?.middleware && Object.keys(middlewareManifest.middleware).length !== 0) {
usingEdge = true
if (process.env.NEXT_DISABLE_NETLIFY_EDGE === 'true' || process.env.NEXT_DISABLE_NETLIFY_EDGE === '1') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just realised I accidentally removed the logic in this

@kodiakhq kodiakhq bot merged commit 8bcbad0 into main Oct 3, 2022
@kodiakhq kodiakhq bot deleted the mk/edge-image-logic branch October 3, 2022 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: latest versions not using edge function for ipx?
2 participants