Skip to content
Proyek

Tentang

: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:

Pengembangan web dan aplikasi

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
-1
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

nextjs-cors

CORS middleware for Next.js API routes.

CI npm version npm downloads license

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

MIT

Jelajahi proyek terkait

Memuat…