Debugging Appwrite CORS Errors!

Welcome! So if you’re here it looks like you’re facing a stubborn CORS bug. Good news, although my error ended up being a niche issue, the debugging steps I used will help with most Appwrite CORs errors. So I was trying to set up the recovery password process for my website that uses Appwrite. Specifically I was setting up account.createRecovery(). But I kept getting this persistent CORS error: Cross-Origin Request Blocked Debugging Step 1: check for typos I thought, maybe there’s a typo or somethings undefined. So I console logged All 3 environmental variables (yours will likely be process.env) data from the form But nope, everything was fine on that front. Debugging Step 2: checking if the hostname was set up as a Appwrite platform Essentially this error is saying there is a mismatch between the “origin” host where the request came from and (ex: dogs.com) the domain of the server, where the request is coming from (ex: cats.com) So in the case of Appwrite, you need to tell Appwrite what strangers (domains) its allowed to talk to it. You might not have your hostname (ex: www.chewy.com) setup as a platform on Appwrite. Localhost should work by default but if you’re having this issue when using your actual domain, then this is worth a shot: go to your project click overview click on integrations and add platform if you see none there I was using local host but I tried every version of localhost and my actual domain I could think of, but no dice

Mar 14, 2025 - 04:22
 0
Debugging Appwrite CORS Errors!

Welcome! So if you’re here it looks like you’re facing a stubborn CORS bug. Good news, although my error ended up being a niche issue, the debugging steps I used will help with most Appwrite CORs errors.

So I was trying to set up the recovery password process for my website that uses Appwrite. Specifically I was setting up account.createRecovery(). But I kept getting this persistent CORS error: Cross-Origin Request Blocked

screen shot of the error message: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cloud.appwrite.io/v1/account/recovery. (Reason: header ‘user-agent’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response).  Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cloud.appwrite.io/v1/account/recovery. (Reason: CORS request did not succeed). Status code: (null).

Debugging Step 1: check for typos

I thought, maybe there’s a typo or somethings undefined.

So I console logged

  • All 3 environmental variables (yours will likely be process.env)

  • data from the form

But nope, everything was fine on that front.

Debugging Step 2: checking if the hostname was set up as a Appwrite platform

Essentially this error is saying there is a mismatch between

  1. the “origin” host where the request came from and (ex: dogs.com)

  2. the domain of the server, where the request is coming from (ex: cats.com)

So in the case of Appwrite, you need to tell Appwrite what strangers (domains) its allowed to talk to it. You might not have your hostname (ex: www.chewy.com) setup as a platform on Appwrite. Localhost should work by default but if you’re having this issue when using your actual domain, then this is worth a shot:

  1. go to your project

  2. click overview

  3. click on integrations and add platform if you see none there

showing that you need to scroll to the bottom of the page to see integrations

I was using local host but I tried every version of localhost and my actual domain I could think of, but no dice