Rank 1: Thread
nothing changed.
I am still wondering about additional cors setting that I could have messed up
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 1: Thread
nothing changed.
I am still wondering about additional cors setting that I could have messed up
Rank 5: Hypervisor
If CORS were the issue, you wouldn't be getting any response. But you are receiving a response from Appwrite
Null or user makes much more sense to me. Otherwise, you have to check if an id is an empty string or something like that
Rank 1: Thread
okay, since I am wondering since I do get a 401 response in the console
06:20:59.845 XHRGEThttp://localhost/v1/account[HTTP/1.1 401 Unauthorized 6ms] GET http://localhost/v1/accountStatus401UnauthorizedVersionHTTP/1.1Übertragen4,00 kB (8,45 kB Größe)Referrer Policystrict-origin-when-cross-originDNS-AuflösungSystem Access-Control-Allow-Credentials true Access-Control-Allow-Headers Origin, Cookie, Set-Cookie, X-Requested-With, Content-Type, Access-Control-Allow-Origin, Access-Control-Request-Headers, Accept, X-Appwrite-Project, X-Appwrite-Key, X-Appwrite-Locale, X-Appwrite-Mode, X-Appwrite-JWT, X-Appwrite-Response-Format, X-Appwrite-Timeout, X-SDK-Version, X-SDK-Name, X-SDK-Language, X-SDK-Platform, X-SDK-GraphQL, X-Appwrite-ID, X-Appwrite-Timestamp, Content-Range, Range, Cache-Control, Expires, Pragma Access-Control-Allow-Methods GET, POST, PUT, PATCH, DELETE Access-Control-Allow-Origin http://localhost:5173 Access-Control-Expose-Headers X-Fallback-Cookies Cache-Control no-cache, no-store, must-revalidate Content-Encoding br Content-Length 2990 Content-Type application/json; charset=UTF-8 Date Mon, 18 Dec 2023 05:20:59 GMT Expires 0 Pragma no-cache Server Appwrite X-Content-Type-Options nosniff X-Debug-Fallback true X-Debug-Speed 0.0024588108062744 Accept */* Accept-Encoding gzip, deflate, br Accept-Language de,en-US;q=0.7,en;q=0.3 Connection keep-alive content-type application/json Host localhost Origin http://localhost:5173 Referer http://localhost:5173/ Sec-Fetch-Dest empty Sec-Fetch-Mode cors Sec-Fetch-Site same-siteRank 1: Thread
okay will change it later . Thank you for your input
What makes you think there's a cors problem?
Rank 5: Hypervisor
The User (role: guests) missing scope (account) in the Exception is coming from the Appwrite backend
Which is expected if you're not logged in
Rank 1: Thread
just guessing around.
Rank 5: Hypervisor
Just pointing out that it can't be CORS
You would get a CORS error if there's a CORS problem so if you're not seeing that, there's no CORS problem
Rank 1: Thread
okay. but why does my catch block not work for the exception?
What's your latest code now?
Rank 1: Thread
this was the attempt removing all other code from a the catch block with account.get inside
the context itself is still the same
export async function getCurrentUser() { var activeAccount = null; try { activeAccount = await account.get(); if (!activeAccount) { throw new Error("get active Account failed"); } console.log("activeAccount", activeAccount.$id); } catch (error: any) { console.log("account.get error: " + error); return error as AppwriteException; } try { const activeUser = await databases.listDocuments( conf.APPWRITE_DATABASE_PLANER, conf.APPWRITE_USERCOLLECTION_ID, [Query.equal("accountID", activeAccount.$id)] ); if (!activeUser) { throw new Error("User not found in Collection"); } console.log("activeuser", activeUser); return activeUser.documents[0]; } catch (error: any) { console.log("getcurrentUser error: " + error); return error as AppwriteException; }}I still think you need to clean this up based on what I said earlier...but anyways, please share a screenshot of the logs from the browser
Rank 1: Thread
the double log entrys come from strict mode
It's going to the catch block...that log is from the catch block...
Rank 1: Thread
oh ...
Rank 1: Thread
I am far over my uptime. I think I need to go to sleep
Rank 1: Thread
but the attempt to call the get() triggers the error log?
Yes. Whenever there's a network request with a 400+ status code, the browser will log it. Regardless of whether you catch it or not
Rank 1: Thread
hmm okay.
I understand that I wasted your time, but I am thankfull for your help.
No worries at all. Nothing is wasted as long as you've learned something
Rank 5: Hypervisor
If your issue has been solved, you can mark this post as closed by adding “[SOLVED]” to the beginning of the title
Rank 1: Thread
[SOLVED] AppwriteException: User (role: guests) missing scope (account)