nothing changed. I am still wondering about additional cors setting that I could have messed up
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
okay, since I am wondering since I do get a 401 response in the console
06:20:59.845 XHRGET
http://localhost/v1/account
[HTTP/1.1 401 Unauthorized 6ms]
GET
http://localhost/v1/account
Status
401
Unauthorized
VersionHTTP/1.1
Übertragen4,00 kB (8,45 kB Größe)
Referrer Policystrict-origin-when-cross-origin
DNS-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-site
okay will change it later . Thank you for your input
What makes you think there's a cors problem?
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
just guessing around.
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
okay. but why does my catch block not work for the exception?
What's your latest code now?
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
the double log entrys come from strict mode
It's going to the catch block...that log is from the catch block...
oh ...
I am far over my uptime. I think I need to go to sleep
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
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
If your issue has been solved, you can mark this post as closed by adding “[SOLVED]” to the beginning of the title
[SOLVED] AppwriteException: User (role: guests) missing scope (account)
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...