#[SOLVED] Fetch for creating account session blocked by CORS ('Access-Control-Allow-Origin')

7 messages · Page 1 of 1 (latest)

rugged marlin
#

I am trying to log in users from my frontend app by calling createEmailSession. The mock user does actually exist, as I have created it manually.
I am using https://cloud.appwrite.io/ and the project id is indeed correct.
What especially bugs me is that yesterday everything worked completely fine. I was able to log in and log out the user without any problems. Today however, it does not work.

I can only think of the following things that could be wrong:

  1. Yesterday I installed nvm because one project required an older version of node. However, I switched back to latest stable version before running the development server.
  2. Yesterday, the address for local dev server was https://localhost:5173/, while today it is http://127.0.0.1:5173/. afaik this should not result in any difference.

I added the response file in har format, should it prove to be helpful. Any help is greatly apprechiated.

plush sierra
#

The second thing is the important one.
To protect your App Appwrite pass the CORS only when:

  • The host name is localhost
  • The host name is one of the Web platforms in that project.

You can add as many web platforms as you need in your project overview page.

rugged marlin
#

Any idea on how to get back to localhost? In both cases I did the exact same thing, i.e. npm run dev, but encountered different outcomes as described above.

plush sierra
#

Your computer treat them the same

rugged marlin
#

Managed to fix the issue.

If anyone has similar problems: make sure you switch back to the exact node version you started the project with before running npm run dev. This seems to have fixed the issue for me.

slim gorge
#

Great!