Skip to content

Instantly share code, notes, and snippets.

@patricktargun
Last active April 27, 2020 16:27
Show Gist options
  • Save patricktargun/0421584ce7b886bad82db51f3598250b to your computer and use it in GitHub Desktop.
Save patricktargun/0421584ce7b886bad82db51f3598250b to your computer and use it in GitHub Desktop.
Handling Reponses [CLOUDFLARE, AWS, NODE.JS]
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