From effe3c5626e66ce24b03940674b61c4a8a450146 Mon Sep 17 00:00:00 2001 From: Cedric Hutchings Date: Thu, 24 Feb 2022 12:14:04 -0500 Subject: [PATCH] add CORS to api/join --- pages/api/join.js | 5 ++--- vercel.json | 18 +++++++++++++++++- yarn.lock | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/pages/api/join.js b/pages/api/join.js index a7ef31e5..e67da3cd 100644 --- a/pages/api/join.js +++ b/pages/api/join.js @@ -7,13 +7,12 @@ const joinTable = new AirtablePlus({ }) export default async function handler(req, res) { - let open = process.env.NEXT_PUBLIC_OPEN == "true" ? true : false if (req.method === 'OPTIONS') { return res - .status(204) - .json({ status: 'YIPPE YAY. YOU HAVE CLEARANCE TO PROCEED.' }) + .status(200) + .send('YIPPE YAY. YOU HAVE CLEARANCE TO PROCEED.'); } if (req.method === 'GET') { return res diff --git a/vercel.json b/vercel.json index ec5d8ab0..a25eebf4 100644 --- a/vercel.json +++ b/vercel.json @@ -1,3 +1,19 @@ { - "github": { "silent": true } + "github": { "silent": true }, + "headers": [ + { + "source": "/api/join", + "headers": [ + { "key": "Access-Control-Allow-Origin", "value": "*" }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" + } + ] + } + ] } diff --git a/yarn.lock b/yarn.lock index 4f1fe4fa..55e6d1a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -265,7 +265,7 @@ lodash "^4.17.19" to-fast-properties "^2.0.0" -"@emotion/babel-plugin@^11.3.0", "@emotion/babel-plugin@^11.7.1": +"@emotion/babel-plugin@^11.7.1": version "11.7.2" resolved "https://registry.yarnpkg.com/@emotion/babel-plugin/-/babel-plugin-11.7.2.tgz#fec75f38a6ab5b304b0601c74e2a5e77c95e5fa0" integrity sha512-6mGSCWi9UzXut/ZAN6lGFu33wGR3SJisNl3c0tvlmb8XChH1b2SUvxvnOh7hvLpqyRdHHU9AiazV3Cwbk5SXKQ==