
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
- Permissions for bulk operation
Hi team, I have a question: “In the databases.createDocuments bulk API, can I set document-level permissions? If yes, how exactly should I include the permissio...
- Limit File Upload count?
Is there a way to limit the number of files a user can upload? I know there's a limit of file size but in my case I'd like to limit the user to only upload x am...
- Function not rebuilding properly
I have a function connected to github. Whenever I push to github it triggers a rebuild as expected, but the new function is not activated after done. Also it ...
