Dichan
28 Jan, 2024, 09:56

These are all my codes. I am having several errors. And also i have integrated in appwrite. I am a beginner in it so can anybody help me ? @Dennis Ivy ??

TL;DR
Issue: CORS causing errors in the project. Solution: 1. Check if the error is `401` unauthorized and redirect the user to the login page. 2. Make sure the `.env` file contains the correct variables: ```.env VITE_APPWRITE_URL=https://cloud.appwrite.io/v1 VITE_APPWRITE_PROJECT_ID=65b3b12a1391d0bfea6c VITE_APPWRITE_DATABASE_ID=65b3b205507b1b098fbb VITE_APPWRITE_COLLECTION_ID=65b3b23d416cb8dba691
Dichan
29 Jan, 2024, 11:49

yes!

Dichan
29 Jan, 2024, 11:50

i have shared my github. Can you please check if there is any error in my code?

kamal.panara
29 Jan, 2024, 11:50

your code is working on machine. i cloned it from your github repo

Dichan
29 Jan, 2024, 11:51

broo..😭

kamal.panara
29 Jan, 2024, 11:51

this is the only error I'm getting after fixing your env

D5
29 Jan, 2024, 11:51

@Dichan Do you have fixed the env?

Dichan
29 Jan, 2024, 11:51

then what has happened with my pc?

Dichan
29 Jan, 2024, 11:52

sorry.. i didn't get you

D5
29 Jan, 2024, 11:52

Do you have fixed what @kamal.panara said?

kamal.panara
29 Jan, 2024, 11:52

also you can fix this by adding catch while calling getCurrentUser()

D5
29 Jan, 2024, 11:52

I think it could be caused due to an old SDK version being used

D5
29 Jan, 2024, 11:53

Or old (vite I think) version

kamal.panara
29 Jan, 2024, 11:54

yes, it can be vite issue, because i have cloned his code from github so appwrite sdk version is same.

kamal.panara
29 Jan, 2024, 11:55

@Dichan can you show me your .env file ?

kamal.panara
29 Jan, 2024, 11:55

your .env file should look like this:

TypeScript
VITE_APPWRITE_URL=https://cloud.appwrite.io/v1
VITE_APPWRITE_PROJECT_ID=65b3b12a1391d0bfea6c
VITE_APPWRITE_DATABASE_ID=65b3b205507b1b098fbb
VITE_APPWRITE_COLLECTION_ID=65b3b23d416cb8dba691
VITE_APPWRITE_BUCKET_ID=65b3b3e5d53648a10ca7
Dichan
29 Jan, 2024, 11:56

give me a sec

Dichan
29 Jan, 2024, 11:58

I have done VITE_APPWRITE_URL_PROJECT_ID so it was creating issue but now i have made it to VITE_APPWRITE_PROJECT_ID and it showed the following in my console. Like actually thank you guys for helping me

Dichan
29 Jan, 2024, 11:58
kamal.panara
29 Jan, 2024, 11:59

finally 😂

Dichan
29 Jan, 2024, 11:59

can you tell me what this 401 unauthorized is?

kamal.panara
29 Jan, 2024, 11:59

now you can catch the error and check if it's 401 unauthorized then redirect user to login page

Dichan
29 Jan, 2024, 11:59

Yea. Thanks brother. I have been seriously stuck for this for about a week and half

kamal.panara
29 Jan, 2024, 12:00

that means user not logged in

Dichan
29 Jan, 2024, 12:00

ok thanks brother

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