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
- HTTP POST to function returning "No Appw...
Hi everyone, I’m running into an issue with my self-hosted Appwrite instance. I’ve set up my environment variables (APPWRITE_FUNCTION_PROJECT_ID, APPWRITE_FUNC...
- Can't add dart 3.5 runtime
Modified the `.env` to enable dart 3.5 runtime on my self-hosted instance but still can't find the runtime when creating a new function. I manually pulled the i...
- How to verify an user using AppWrite Fun...
I have seen similar questions but none whose solutions serve me. I have a function to verify a user with their secret and their id: https://blahblah.appwrite.gl...