Skip to content

Files

Latest commit

 

History

History
26 lines (15 loc) · 636 Bytes

no-server-import-in-page.md

File metadata and controls

26 lines (15 loc) · 636 Bytes

Pattern: next/server imported outside of middleware.{js,ts}

Issue: -

Description

next/server was imported outside of middleware.{js,ts}.

Possible Ways to Fix It

Only import and use next/server in a file located within the project root directory: middleware.{js,ts}.

// middleware.ts

import type { NextFetchEvent, NextRequest } from 'next/server'

export function middleware(req: NextRequest, ev: NextFetchEvent) {
  return new Response('Hello, world!')
}

Further Reading