From 8c1fdb3f62f6c4b1151fe22a5e9cfc90c871a5e0 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Thu, 18 Jun 2020 13:14:17 +0000 Subject: [PATCH] Attempt to fix CORS --- pages/api/som-join.js | 3 +++ vercel.json | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pages/api/som-join.js b/pages/api/som-join.js index 80e77225..ff9f8ee1 100644 --- a/pages/api/som-join.js +++ b/pages/api/som-join.js @@ -7,6 +7,9 @@ const joinTable = new AirtablePlus({ }) export default async (req, res) => { + if (req.method == 'OPTIONS') { + return res.status(204).json({ status: "YIPPE YAY. YOU HAVE CLEARANCE TO PROCEED." }) + } if (req.method == 'GET') { return res.status(405).json({ error: '*GET outta here!* (Method not allowed, use POST)' }) } diff --git a/vercel.json b/vercel.json index ffeab757..96586cdd 100644 --- a/vercel.json +++ b/vercel.json @@ -6,7 +6,10 @@ "headers": [ { "source": "/api/(.+)", - "headers": [{ "key": "Access-Control-Allow-Origin", "value": "*" }] + "headers": [ + { "key": "Access-Control-Allow-Origin", "value": "*" }, + { "key": "Access-Control-Allow-Methods", "value": "POST, OPTIONS" } + ] } ] }