From d840674d2ade31a81bb401052caa06ec36bd6b6b Mon Sep 17 00:00:00 2001 From: Anda Toshiki <101481353+andatoshiki@users.noreply.github.com> Date: Thu, 9 May 2024 01:36:33 -0700 Subject: [PATCH] fix(cors): update allowed access origin to wildcard yet again avoiding content fetching failure when utilizing get method for http access --- netlify/functions/getLastFmSongs.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/netlify/functions/getLastFmSongs.ts b/netlify/functions/getLastFmSongs.ts index 2f2be4d..7d49f87 100755 --- a/netlify/functions/getLastFmSongs.ts +++ b/netlify/functions/getLastFmSongs.ts @@ -22,7 +22,7 @@ const handler: Handler = async () => { ] // Origin for CORS - // const origin = process.env.NODE_ENV === 'production' ? 'https://toshiki.dev' : 'http://localhost:3000' + const origin = process.env.NODE_ENV === 'production' ? 'https://toshiki.dev' : 'http://localhost:3000' // Map track function const mapTrack = (track: any): any => { @@ -68,11 +68,9 @@ const handler: Handler = async () => { return { statusCode: 200, error: false, - // headers: { - // 'Access-Control-Allow-Origin': origin, - // 'Access-Control-Allow-Headers': 'Content-Type', - // 'Access-Control-Allow-Methods': 'GET' - // }, + headers: { + 'access-control-allow-origin': '*' + }, body: JSON.stringify({ user: formattedUserInfo, recentTracks: recentTracks?.tracks?.map(mapTrack) || [],