
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
- Cannot find module failure
Sorry, Newbe question here. I just installed Appwrite and am trying to install my first Function an am having absolutely no luck what-so-ever getting this done...
- Can't push functions when self-hosting o...
Hello, I'm a bit new to appwrite functions and recently hosted a fresh 1.7.4 on my portainer setup. Tried to create a new function and when trying to push it I ...
- Internal curl errors has occurred within...
