Skip to content
Projekte

Über uns

: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- und App-Entwicklung

So werden diese Zahlen gemessen

Gemessener Sternzuwachs

in 24h
0
in 7 days
0
in 15 days
-1
in 1 month
Verlauf wird gesammelt

Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.

README.md

Original

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

Ähnliche Projekte entdecken

Wird geladen…