So that's in your function code?
CORS issue with new functions custom domain
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
yes
Rank 3: Container
there is no response, just cors errors
Is that first one an option request?
Rank 3: Container
i think its just react calling the post request two times
Is there an options request further back?
Rank 3: Container
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?
Rank 3: Container
yes it works if i just open it or in postman
Rank 3: Container
oh there is an options request right after it
Did it fail? What are the details for it?
Rank 3: Container
nope it doesnt seem to fail
Rank 3: Container
what details? there is no response or anything so
Maybe try again? Sometimes the browser clears out the response
Rank 3: Container
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?
Rank 3: Container
in appwrite functions how do you set headers when using res.json
What's your runtime?
Rank 3: Container
node js 18
Rank 3: Container
ohk got it
Rank 3: Container
Yep it works now.
setting {"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "Content-Type"} works.
Rank 3: Container
@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?
Rank 3: Container
Will give it a try