Last active
April 27, 2020 16:27
-
-
Save patricktargun/0421584ce7b886bad82db51f3598250b to your computer and use it in GitHub Desktop.
Handling Reponses [CLOUDFLARE, AWS, NODE.JS]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const corsHeaders = { | |
'Access-Control-Allow-Origin': '*', | |
'Access-Control-Allow-Credentials': true, | |
} | |
// CLOUDFLARE | |
event.respondWith( | |
return new Response(JSON.stringify(data), { | |
status: 200, | |
headers: corsHeaders | |
}) | |
) | |
// AWS LAMBDA | |
return { | |
statusCode: 200, | |
headers: corsHeaders, | |
body: JSON.stringify(body) | |
}; | |
// NODE.JS | |
res.status(200); | |
return res.json({}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment