cors1 NextJS를 API로만 이용할때 CORS 에러 대처 방법 파일명은 middleware.ts으로 사용되야 하고 위치는 루트(/) 위치 즉 package.json 파일 위치와 같아야 한다. import { NextResponse } from "next/server"; // the list of all allowed origins const allowedOrigins = [ 'http://localhost:3011', ]; export function middleware(req: any) { // retrieve the current response const res = NextResponse.next() // retrieve the HTTP "Origin" header // from the incoming request let origin = req.headers.. 2023. 8. 8. 이전 1 다음