项目
在 GitHub 查看
yonycalsin/nextjs-cors
关于
:tada: nextjs-cors is a node.js package to provide a Connect/Express middleware that can be used to enable CORS with various options :rocket:
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文nextjs-cors
CORS middleware for Next.js API routes.
Installation
npm install nextjs-cors
# or
yarn add nextjs-cors
# or
pnpm add nextjs-cors
Usage
import NextCors from "nextjs-cors";
export default async function handler(req, res) {
// Run CORS middleware
await NextCors(req, res, {
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
origin: "*",
optionsSuccessStatus: 200,
});
// Your API logic
res.json({ message: "Hello NextJs Cors!" });
}
Options
This package uses the cors package. See the cors documentation for all available options.
License
探索相关项目
加载中…