Back

No 'Access-Control-Allow-Origin' localhost - Vite-React

  • 0
  • Web
Sembian
25 Nov, 2023, 23:08

Hi, I am trying to create a new user sign-up for an application using Vite and React and when connecting with appwrite client getting CORS error, tried adding the localhost as pltform in appwrite Access to XMLHttpRequest at 'https://cloud.appwrite.io/v1/account' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. api.ts:16 AppwriteException: Network request failed at Client.<anonymous> (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=da635d55:862:15) at Generator.throw (<anonymous>) at rejected (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=da635d55:495:32) SignupForm.tsx:42 AppwriteException: Network request failed at Client.<anonymous> (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=da635d55:862:15) at Generator.throw (<anonymous>) at rejected (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=da635d55:495:32) api.ts:8

TypeScript
   POST https://cloud.appwrite.io/v1/account net::ERR_FAILED 404 (Not Found)
TL;DR
The user is experiencing a CORS error while trying to create a user sign-up using Vite and React with an Appwrite client. They have added localhost as a platform in Appwrite, but the issue persists. The error message suggests that the 'Access-Control-Allow-Origin' header is missing from the requested resource, causing the network request to fail. A possible solution is to check the network logs in the browser's dev tools and share the request headers.
Sembian
25 Nov, 2023, 23:16

No 'Access-Control-Allow-Origin' localhost - Vite-React

Drake
26 Nov, 2023, 02:36

Please make sure your project id is set and correct

Sembian
26 Nov, 2023, 11:09

@Drake Appreciate the help, the project it is set and endpoint is correct but still getting the CORS error - I added a Web Platform integration with localhost but still not resolved

Drake
26 Nov, 2023, 15:25

Would you please check the network logs for the request in your browser's dev tools? Please share the request hearers

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