
So that's in your function code?

yes

there is no response, just cors errors

Is that first one an option request?

i think its just react calling the post request two times

Is there an options request further back?

well right before, i am getting the user's jwt token to pass into the function, that is an option request

Ugh I wonder if the request is hidden by the browser...
Does the url work if you just open it in the browser url?

yes it works if i just open it or in postman

oh there is an options request right after it

Did it fail? What are the details for it?

nope it doesnt seem to fail

what details? there is no response or anything so

Maybe try again? Sometimes the browser clears out the response

there is no response

So I'm actually starting to think we don't automatically send back that allow origin header for these function routes. Can you try updating your function code to set the allow origin header to * for testing?

in appwrite functions how do you set headers when using res.json

What's your runtime?

node js 18


ohk got it

Yep it works now.
setting {"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "Content-Type"}
works.

@Steven but there is an issue, if the function times out or if some unexpected error happens the cors issue would happen since the header is not set in that case

Can you try to implement the options method to only return the allow headers?

Will give it a try
Recommended threads
- Appwrite messaging api error
```=== Push Notification Function Started === Endpoint: https://fra.cloud.appwrite.io/v1 Project: 6899062700398ffeae4f Database: threed-dating-db Notification f...
- function unable to detect client ip
Hi I have hosted appwrite on self hosted server. Currently I don't have any domain. I am accessing through ip. I have created one function which should detect t...
- Appwrite Cloud Function runs forever, ev...
It just keeps running, and there's no way to manually stop it.
