no-server-import-in-page.mdx
title: No Server Import In Page
Prevent usage of
next/serveroutside ofproxy.js.
Why This Error Occurred
next/server was imported outside of proxy.{js,ts}.
Possible Ways to Fix It
Only import and use next/server in a file located within the project root directory: proxy.{js,ts}.
import type { NextFetchEvent, NextRequest } from 'next/server'
export function proxy(req: NextRequest, ev: NextFetchEvent) {
return new Response('Hello, world!')
}
Useful Links
Rendered from the public repository vercel/next.js on GitHub; content belongs to its authors. Cached for up to an hour.