Skip to content

Conversation

@pilcrowonpaper
Copy link

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Nov 20, 2025

⚠️ No Changeset found

Latest commit: 4e4a7f9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

status: 508,
});
}
throw new Error("Failed to fetch image");
Copy link
Author

Choose a reason for hiding this comment

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

This is consistent with Next.js but not sure if a 500 response is the best if the URL is invalid

@sommeeeer
Copy link
Collaborator

Hello @pilcrowonpaper, good to see you here :) looks good on first glance, I'll do another review later!

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 20, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@999

commit: 4e4a7f9

} else {
const cacheControlHeader = imageResponse.headers.get("Cache-Control");
if (cacheControlHeader !== null) {
immutable = cacheControlHeader.includes("immutable");
Copy link
Author

Choose a reason for hiding this comment

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

Next.js does something more complicated and bases the optimized response on the upstream Cache-Control header. I didn't want to do anything complex for now so it just checks if the upstream image is a static content

@pilcrowonpaper
Copy link
Author

It looks like the Playwright tests are failing because the test cases don't include the required w and q parameters.

const __IMAGES_CONTENT_DISPOSITION__ = JSON.stringify(
imagesManifest?.images?.contentDispositionType ?? "attachment"
);
const __IMAGES_MAX_REDIRECTS__ = JSON.stringify(imagesManifest?.images?.maximumRedirects ?? 3);
Copy link
Author

Choose a reason for hiding this comment

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

This was changed to 3 from unlimited in Next.js 16


const defaultDeviceSizes = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
const defaultImageSizes = [32, 48, 64, 96, 128, 256, 384];
const defaultQualities = [75];
Copy link
Author

Choose a reason for hiding this comment

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

Before Next.js 16, the default behavior was to allow values from 1-100

}

const defaultDeviceSizes = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
const defaultImageSizes = [32, 48, 64, 96, 128, 256, 384];
Copy link
Author

Choose a reason for hiding this comment

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

Before Next.js 16, 16 was also included

async function fetchImage(url: string, count: number): Promise<FetchImageResult> {
let response: Response;
try {
response = await fetch(url, {
Copy link
Author

Choose a reason for hiding this comment

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

I haven't added support for dangerouslyAllowLocalIP, which checks if a domain resolves to a private IP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants