cloudflare/vinext

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

Fechada

#1.570 aberto em 22 de mai. de 2026

 (1 comentário) (0 reação) (1 responsável)TypeScript (383 forks)github user discovery
adapter-api-e2ehelp wanted

Métricas do repositório

Stars
 (8.624 estrelas)
Métricas de merge de PR
 (Mesclagem média 1d 1h) (462 fundiu PRs em 30d)

Description

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.

Guia do colaborador