Back

How to CORS for function's custom domain?

  • 0
  • Cloud
gokulsiva
4 Jul, 2024, 23:15

Hi, I couldn't find a way to solve cors for the function with the custom domain I've added. For Project level custom domain it is handled by the hostname and platform combination.

Please share me the solution / workaround if any.

TL;DR
To enable CORS for a function with a custom domain, developers need to manually add the CORS headers to their response. An example of allowing all origins is: ```js return res.json(response, 200, {'Access-Control-Allow-Origin': '*'}); ``` For project-level custom domains, CORS is handled by the combination of the hostname and platform. Developers must add the necessary CORS headers to their function's response for CORS to work properly.
Binyamin
4 Jul, 2024, 23:44

You'll need to add the CORS yourself For example allow all

TypeScript
return res.json(response,200,{'Access-Control-Allow-Origin': '*',})
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more