D
Deno

help

How to setup CORS with serve? I get 403 forbidden.

Ffrigjord9/30/2022
I've setup the following headers (OPTIONS response):
new Response(null, {
status: 204,
headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', 'Access-Control-Allow-Headers': '*' }
})
new Response(null, {
status: 204,
headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', 'Access-Control-Allow-Headers': '*' }
})
I'm getting 403 when the request has Access-Control-Request-Method: OPTIONS. Which is what the browser send. Without that, it replies with 204 as expected.

Looking for more? Join the community!