cleanup no cors middleware
parent
02855ef020
commit
04052c53b4
|
@ -1,17 +0,0 @@
|
||||||
import type { NextMiddleware } from "next-api-middleware";
|
|
||||||
import NextCors from "nextjs-cors";
|
|
||||||
|
|
||||||
export const withCors: NextMiddleware = async (req, res, next) => {
|
|
||||||
// Run the cors middleware
|
|
||||||
// nextjs-cors uses the cors package, so we invite you to check the documentation https://github.com/expressjs/cors
|
|
||||||
await NextCors(req, res, {
|
|
||||||
// Options
|
|
||||||
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
|
|
||||||
origin: "*",
|
|
||||||
optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204
|
|
||||||
});
|
|
||||||
|
|
||||||
// Rest of the API logic
|
|
||||||
// Execute the remaining middleware
|
|
||||||
await next();
|
|
||||||
};
|
|
|
@ -1,12 +0,0 @@
|
||||||
import { label } from "next-api-middleware";
|
|
||||||
|
|
||||||
import { withCors } from "./withCors";
|
|
||||||
|
|
||||||
const withCorsMiddleware = label(
|
|
||||||
{
|
|
||||||
withCors,
|
|
||||||
},
|
|
||||||
["withCors"] // <-- Provide a list of middleware to call automatically
|
|
||||||
);
|
|
||||||
|
|
||||||
export { withCorsMiddleware };
|
|
|
@ -2,8 +2,6 @@ import jsonSchema from "@/json-schema/json-schema.json";
|
||||||
import pjson from "@/package.json";
|
import pjson from "@/package.json";
|
||||||
import { withSwagger } from "next-swagger-doc";
|
import { withSwagger } from "next-swagger-doc";
|
||||||
|
|
||||||
import { withCorsMiddleware } from "@lib/helpers/withCorsMiddleware";
|
|
||||||
|
|
||||||
const swaggerHandler = withSwagger({
|
const swaggerHandler = withSwagger({
|
||||||
definition: {
|
definition: {
|
||||||
openapi: "3.0.0",
|
openapi: "3.0.0",
|
||||||
|
|
Loading…
Reference in New Issue