cloudflare / cloudflare-docs

Cloudflare’s documentation
https://developers.cloudflare.com
Creative Commons Attribution 4.0 International
3.07k stars 4.71k forks source link

Integration with frameworks ​​ Next.js #4481

Closed Framsynt closed 2 years ago

Framsynt commented 2 years ago

Existing documentation URL(s)

- link(s) to existing https://developers.cloudflare.com/... pages

Section that requires update

Next.js

NOTE: Please name or describe the section as not all page sections have header-links and section IDs may change over time.

What needs to change?

return `/cdn-cgi/image/${paramsString}/${normalizeSrc(src)}`;

this does not work with local development 'yarn dev' etc.

How should it change?

add if (process.env.NODE_ENV === 'development') or similar solution.

Additional information

Any other details or screenshots that may be relevant.

Framsynt commented 2 years ago

Oh, just noticed that whole MyImage return is wrong too.

sejoker commented 2 years ago

@Framsynt I don't think we can provide a reliable setup for local development in the example. We can consider adding a note that additional changes are necessary for local development. How does it sounds to you?

sejoker commented 2 years ago

Note:

For local development you can enable [Resize images from any origin checkbox](https://developers.cloudflare.com/images/image-resizing/enable-image-resizing/) against your zone and return an absolute URL path:
return `https://<yourdomain.com>/cdn-cgi/image/${paramsString}/${normalizeSrc(src)}`;
Framsynt commented 2 years ago

👌

marciocloudflare commented 2 years ago

Closing. Addressed in https://github.com/cloudflare/cloudflare-docs/pull/4531