mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
15fbe66c47
Adds Pages Router fixtures and dev + production integration tests for the
two scenarios reported as failing in the Next.js Deploy Suite:
- `export const config = { runtime: 'edge' }` API route returns a Web
Response (issue #1338 case 1 — edge API routes were observed as 500).
- `next/og` `ImageResponse` with `runtime: 'edge'` inside a Pages Router
API route returns `image/png` (issue #1338 case 2 — OG routes were
observed as 404).
Ports route handlers from `next.js/test/e2e/edge-pages-support/app/pages/api/hello.js`
and `next.js/test/e2e/og-api/app/pages/api/og.js`. The existing
implementation already wires both code paths correctly via
`handlePagesApiRoute` and the `vinext:og-inline-fetch-assets` plugin; this
PR locks in coverage so a Pages Router-only build cannot silently regress
either path.
Refs #1338
23 lines
878 B
TypeScript
23 lines
878 B
TypeScript
// Ported from Next.js: test/e2e/edge-pages-support/app/pages/api/hello.js
|
|
// https://github.com/vercel/next.js/blob/canary/test/e2e/edge-pages-support/app/pages/api/hello.js
|
|
//
|
|
// Pages Router edge runtime API route. The handler receives a NextRequest
|
|
// (Fetch-style) instead of (req, res), and must return a Web Response.
|
|
// Regression coverage for cloudflare/vinext#1338 — edge runtime API routes
|
|
// were reported as returning 500 against the Next.js deploy suite.
|
|
export const config = {
|
|
runtime: "edge",
|
|
};
|
|
|
|
type NextRequestLike = Request & { nextUrl: { searchParams: URLSearchParams } };
|
|
|
|
export default async function handler(req: NextRequestLike): Promise<Response> {
|
|
return new Response(
|
|
JSON.stringify({
|
|
hello: "world",
|
|
query: Object.fromEntries(req.nextUrl.searchParams),
|
|
}),
|
|
{ headers: { "content-type": "application/json" } },
|
|
);
|
|
}
|