nextjs cors
v2.2.0
Nextjs-Cors 는 NEXTJS 애플리케이션에서 다양한 옵션을 제공하는 데 사용할 수있는 미들웨어를 제공하는 Node.js 패키지입니다.
먼저이 멋진 패키지를 사용하려면 설치해야합니다.
# Using npm
npm install nextjs-cors@latest
# Using yarn
yarn add nextjs-cors@latest
# Using pnpm
pnpm add nextjs-cors@latestNextJS-Cors는 CORS 패키지를 사용하므로 문서를 확인하도록 초대합니다 https://github.com/expressjs/cors
Pages/API/Whoami. {TS, JS}
import NextCors from 'nextjs-cors' ;
async function handler ( req , res ) {
// Run the cors middleware
// nextjs-cors uses the cors package, so we invite you to check the documentation https://github.com/expressjs/cors
await NextCors ( req , res , {
// Options
methods : [ 'GET' , 'HEAD' , 'PUT' , 'PATCH' , 'POST' , 'DELETE' ] ,
origin : '*' ,
optionsSuccessStatus : 200 , // some legacy browsers (IE11, various SmartTVs) choke on 204
} ) ;
// Rest of the API logic
res . json ( { message : 'Hello NextJs Cors!' } ) ;
} 라이센스에 따른 nextjs-cors .