1fbbba6ffe
This serves to start the transition of replacing the following: - Replace `BaseNextRequest`, `WebNextRequest`, and `NodeNextRequest` with `NextRequest` - Replace `BaseNextResponse`, `WebNextResponse`, and `NodeNextResponse` with `Response` This will currently only apply to app routes, enabling the following: ```ts //////////////////////////////////////////////////////////////////////////////// // Use `Request` and `Response` //////////////////////////////////////////////////////////////////////////////// import { NextRequest, NextResponse } from 'next/server' export function GET(request: Request): Response { return new Response( JSON.stringify({ hello: request.headers.get('user-agent'), }), { headers: { 'content-type': 'application/json' } } ) } //////////////////////////////////////////////////////////////////////////////// // Use `NextRequest` and `NextResponse` //////////////////////////////////////////////////////////////////////////////// import { NextRequest, NextResponse } from 'next/server' export function GET(request: NextRequest): NextResponse { return NextResponse.json({ hello: request.headers.get('user-agent') }) } //////////////////////////////////////////////////////////////////////////////// // Use `NextRequest` and `Response` //////////////////////////////////////////////////////////////////////////////// import { NextRequest, NextResponse } from 'next/server' // `NextRequest` extends `Request`. export function GET(request: NextRequest): Response { return new Response( JSON.stringify({ hello: request.headers.get('user-agent') }), { headers: { 'content-type': 'application/json' } } ) } //////////////////////////////////////////////////////////////////////////////// // Use `NextRequest`, `NextResponse`, and `Response` //////////////////////////////////////////////////////////////////////////////// import { NextRequest, NextResponse } from 'next/server' export function GET(request: NextRequest): Response { // `NextResponse` extends `Response`. return NextResponse.json({ hello: request.headers.get('user-agent') }) } //////////////////////////////////////////////////////////////////////////////// // Use `Request` and `NextResponse` //////////////////////////////////////////////////////////////////////////////// import { NextRequest, NextResponse } from 'next/server' export function GET(request: Request): NextResponse { return NextResponse.json({ hello: request.headers.get('user-agent') }) } ``` fix NEXT-713 |
||
---|---|---|
.. | ||
.stats-app | ||
__mocks__ | ||
development | ||
e2e | ||
examples | ||
integration | ||
lib | ||
production | ||
unit | ||
.gitignore | ||
jest-setup-after-env.ts | ||
jest.d.ts | ||
readme.md | ||
test-file.txt |