OccultSlolem
OccultSlolem3y ago

CORS headers for HTTP endpoints

One last question for you guys: how do I set access control headers for my HTTP endpoints?
2 Replies
ballingt
ballingt3y ago
The Response object constructed in an HTTP endpoint can have headers passed to it, you need to add these; something like
const response = new Response(content, {
headers: {
'Access-Control-Allow-Origin': '*',
}
});
const response = new Response(content, {
headers: {
'Access-Control-Allow-Origin': '*',
}
});
sshader
sshader3y ago
I found https://stackoverflow.com/questions/66486610/how-to-set-cors-in-cloudflare-workers somewhat helpful (also stay tuned for a blog post or further docs on this at some point)
Stack Overflow
How to set CORS in Cloudflare Workers?
I'm a newbie in Cloudflare Workers. How to set CORS in Cloudflare Workers? response = await cache.match(cacheKey); if (!response) { // handle fetch data and cache } const myHeaders = new

Did you find this page helpful?