Deployment Test

This commit is contained in:
Benjamin Toby 2024-10-05 12:11:28 +01:00
parent 3acd96209c
commit f8d31a4060

View File

@ -8,7 +8,11 @@ const cors = Cors({
// Helper method to wait for a middleware to execute before continuing // Helper method to wait for a middleware to execute before continuing
// And to throw an error when an error happens in a middleware // And to throw an error when an error happens in a middleware
function runMiddleware(req: NextApiRequest, res: NextApiResponse, fn: Function) { function runMiddleware(
req: NextApiRequest,
res: NextApiResponse,
fn: Function
) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fn(req, res, (result: any) => { fn(req, res, (result: any) => {
if (result instanceof Error) { if (result instanceof Error) {
@ -20,23 +24,20 @@ function runMiddleware(req: NextApiRequest, res: NextApiResponse, fn: Function)
}); });
} }
/** export default async function handler(
* @type {NextApiHandler} req: NextApiRequest,
*/ res: NextApiResponse
export default async function handler(req: NextApiRequest, res: NextApiResponse) { ) {
// res.setHeader("Access-Control-Allow-Credentials", "true");
// res.setHeader("Access-Control-Allow-Origin", "*");
// res.setHeader("Access-Control-Allow-Methods", "*");
// res.setHeader("Access-Control-Allow-Headers", "*");
res.setHeader("Access-Control-Allow-Credentials", "true"); res.setHeader("Access-Control-Allow-Credentials", "true");
res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Origin", "*");
// another common pattern res.setHeader(
// res.setHeader('Access-Control-Allow-Origin', req.headers.origin); "Access-Control-Allow-Methods",
res.setHeader("Access-Control-Allow-Methods", "GET,OPTIONS,PATCH,DELETE,POST,PUT"); "GET,OPTIONS,PATCH,DELETE,POST,PUT"
res.setHeader("Access-Control-Allow-Headers", "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version"); );
res.setHeader(
// await runMiddleware(req, res, cors); "Access-Control-Allow-Headers",
"X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version"
);
res.json({ res.json({
title: "Hello There", title: "Hello There",