fix: OPTIONS being blocked

This commit is contained in:
diced 2022-11-24 10:35:06 -08:00
parent 8e1541ea56
commit 1b6af9fc08
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1

View file

@ -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.