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
- Cloudflare output appearing in function ...
Hello everyone! My function execution failed and it showing Cloudflare output in the execution log. It leaks the IP (DigitalOcean) as well. It's not the first ...
- How to access oldValue payload in functi...
I want to record old and new values of data changes as audits. But when i try to read row in function. The value is new already even before grt updated
- Fails to add Custom domain and subdomain...
Case 1 : I've a domain ("remiel.work") which i want to host my portfolio thru appwrite sites. when i try to connect my domain (which i bought from spaceship, ma...