Skip to content
Back

Getting Cors Error in appwrite functions during any request from the client side using react.

  • 0
  • Web
Safi Hyder
25 Feb, 2025, 10:17
TL;DR
Developers facing Cors Error in appwrite functions during requests from client side using React. Ensure handling `OPTIONS` request, set `Access-Control-Allow-Origin` to `localhost`, and respond to `OPTIONS` requests with the CORS headers. Consider using `functions.createExecution()` as an alternative solution for returning the correct CORS headers.
ideclon
25 Feb, 2025, 10:17

I believe you’ll need to return the correct CORS headers in your Function, there

ideclon
25 Feb, 2025, 10:18

Alternatively, you can use functions.createExecution()

Safi Hyder
25 Feb, 2025, 10:18
ideclon
25 Feb, 2025, 10:19

I believe CORS just uses the hostname

ideclon
25 Feb, 2025, 10:19

Not a whole URL

Safi Hyder
25 Feb, 2025, 10:31

I Tried but stiil getting the same error

ideclon
25 Feb, 2025, 10:33

Make sure you’re responding to OPTIONS requests with the CORS headers.

ideclon
25 Feb, 2025, 10:33

Oh, wait - I see you are

ideclon
25 Feb, 2025, 10:33

You’ve set all the Access-Control-Allow-Origins to just localhost?

Safi Hyder
25 Feb, 2025, 10:38

Firstly i tried it using "*" but didn't work

ideclon
25 Feb, 2025, 10:38

Have you tried making the request with cURL or Postman to confirm the headers are returned?

Safi Hyder
25 Feb, 2025, 10:44

I tried it but it is showing the internal server error 500

Safi Hyder
25 Feb, 2025, 10:46

I can share my screen if you want to solve this error

ideclon
25 Feb, 2025, 10:52

You are trying an OPTIONS request, yes? You don’t seem to have any GET handler, so GET requests will throw a 500 from what I can see of your code.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more