cloudflare/vinext

Build: `/_next/image` optimization endpoint returns 400 / `text/html` instead of optimized image

Geschlossen

#1.570 geöffnet am 22.05.2026

 (1 Kommentar) (0 Reaktionen) (1 zugewiesene Person)TypeScript (385 Forks)github user discovery
adapter-api-e2ehelp wanted

Repository-Metriken

Stars
 (8.633 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 1T 1h) (462 gemergte PRs in 30 T)

Beschreibung

Follow-up to #1513 / #1562. The URL prefix rename (/_vinext/image/_next/image) was split into #1562 as a small isolated patch. The remaining part of #1513 needs its own work:

Problem (remaining)

vinext's image optimization endpoint at /_next/image returns 400 with content-type: text/html instead of the optimized image bytes:

Expected content-type: image/png | Received: text/html

Next.js's /_next/image?url=...&w=...&q=...&dpl=... endpoint must respond with the optimized image (or a redirect to one). Two reasonable implementations:

  1. On-the-fly optimization at the worker — port (or adapt) Next.js's image optimization pipeline.
  2. Proxy to Cloudflare Images — let the platform do the resizing.

Reference

  • .nextjs-ref/test/e2e/app-dir/next-image/next-image.test.ts
  • .nextjs-ref/packages/next/src/server/image-optimizer.ts

Estimated impact

~9 e2e test failures remaining after #1562.

Recommendation

  1. Reproduce in vinext's own test suite: hit /_next/image?url=... with a static asset path; assert the response has content-type: image/<format> and a 200 status.
  2. Decide between on-the-fly vs Cloudflare Images proxy (the latter is likely simpler for the Workers runtime).
  3. Implement the endpoint behind the existing IMAGE_OPTIMIZATION_PATH constant.

Part of #1328.

Contributor Guide