cloudflare/vinext

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

已關閉

#1,570 建立於 2026年5月22日

 (1 則留言) (0 個反應) (1 位負責人)TypeScript (386 個分叉)github user discovery
adapter-api-e2ehelp wanted

倉庫指標

星標
 (8,635 顆星)
PR 合併指標
 (平均合併 1天 1小時) (30 天內合併 462 個 PR)

描述

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.

貢獻者指南