cloudflare/vinext

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

クローズ

#1,570 opened on 2026/05/22

 (1 件のコメント) (0 件のリアクション) (1 人の担当者)TypeScript (383 件のフォーク)github user discovery
adapter-api-e2ehelp wanted

Repository metrics

Stars
 (8,624 個のスター)
PR merge metrics
 (平均マージ 1d 1h) (30d で 462 merged PRs)

説明

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.

コントリビューターガイド