プロジェクト
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:
Web・アプリ開発計測したスター増加
- 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
関連プロジェクトを探す
読み込み中…