-
SummaryThe Next.js docs say:
…however, I can add the following import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
export function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith("/foo")) {
return NextResponse.redirect(new URL("/bar", request.url));
}
} …and when I run Am I missing something or the docs are misleading? Additional informationOperating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64
Available memory (MB): 32768
Available CPU cores: 16
Binaries:
Node: 20.16.0
npm: 10.8.1
Yarn: 1.22.19
pnpm: 9.8.0
Relevant Packages:
next: 14.2.5
eslint-config-next: 14.2.5
react: 18.3.1
react-dom: 18.3.1
typescript: 5.5.4
Next.js Config:
output: N/A ExampleNo response |
Beta Was this translation helpful? Give feedback.
Answered by
Juneezee
Aug 30, 2024
Replies: 1 comment 1 reply
-
Your code works because you are not using any Node.js APIs that are not available in the Edge Runtime. See the Unsupported APIs section of Edge Runtime 1. Footnotes |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hdodov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your code works because you are not using any Node.js APIs that are not available in the Edge Runtime. See the Unsupported APIs section of Edge Runtime 1.
Footnotes
https://nextjs.org/docs/app/api-reference/edge#unsupported-apis ↩