From 5f1a54a36312b4d69f471784f1574ddc5f579992 Mon Sep 17 00:00:00 2001 From: "youtsteve1@gmail.com" Date: Sat, 20 Jul 2024 13:06:39 +0300 Subject: [PATCH] updated video sources --- pages/middleware.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pages/middleware.js diff --git a/pages/middleware.js b/pages/middleware.js new file mode 100644 index 0000000..9aa0108 --- /dev/null +++ b/pages/middleware.js @@ -0,0 +1,22 @@ +import { NextResponse } from "next/server"; + +export function middleware() { + // retrieve the current response + const res = NextResponse.next() + + // add the CORS headers to the response + res.headers.append('Access-Control-Allow-Credentials', "true") + res.headers.append('Access-Control-Allow-Origin', '*') // replace this your actual origin + res.headers.append('Access-Control-Allow-Methods', 'GET,DELETE,PATCH,POST,PUT') + res.headers.append( + 'Access-Control-Allow-Headers', + 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version' + ) + + return res +} + +// specify the path regex to apply the middleware to +export const config = { + matcher: '/api/:path*', +}