From 1b6af9fc08ec4933f34db24b51dfd001665ee27f Mon Sep 17 00:00:00 2001 From: diced Date: Thu, 24 Nov 2022 10:35:06 -0800 Subject: [PATCH] fix: OPTIONS being blocked --- src/lib/middleware/withZipline.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/middleware/withZipline.ts b/src/lib/middleware/withZipline.ts index 00546ec..b17d040 100644 --- a/src/lib/middleware/withZipline.ts +++ b/src/lib/middleware/withZipline.ts @@ -59,9 +59,11 @@ export const withZipline = api_config: ZiplineApiConfig = { methods: ['GET'] } ) => (req: NextApiReq, res: NextApiRes) => { + api_config.methods.push('OPTIONS'); + res.setHeader('Content-Type', 'application/json'); res.setHeader('Access-Control-Allow-Origin', '*'); - res.setHeader('Access-Content-Allow-Methods', 'GET,HEAD,POST,OPTIONS'); + res.setHeader('Access-Content-Allow-Methods', api_config.methods.join(',')); res.setHeader('Access-Control-Max-Age', '86400'); // Used when the client sends wrong information, etc.