From a2fc7ec460a77e3631b87c5dd4fdb47f89fee5c3 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Tue, 7 Nov 2023 15:28:26 -0600 Subject: [PATCH] Updated config and OPTIONS method for function. --- netlify/functions/users/users.mts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/netlify/functions/users/users.mts b/netlify/functions/users/users.mts index 521d3c5..6f719fd 100644 --- a/netlify/functions/users/users.mts +++ b/netlify/functions/users/users.mts @@ -191,15 +191,16 @@ export default async (req: Request): Promise => { if (authorizeUserResponse.status != 200) { throw new Error('could not authorize user'); } - const origin = req.headers['origin']; + const origin = req.headers.get('origin'); + console.log(origin); return new Response( 'OK', { - headers: { - 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': origin ? origin : 'https://cameras.immersiveidea.com', - 'Access-Control-Allow-Credentials': 'true' - }, + headers: [ + ['Content-Type', 'application/json'], + ['Access-Control-Allow-Origin', origin], + ['Access-Control-Allow-Credentials', 'true'] + ], status: 200 } )