fix: don't send authentication if user is not authenticated (@fehmer (#5747)

This commit is contained in:
Christian Fehmer 2024-08-08 19:00:02 +02:00 committed by GitHub
parent 45d27b5e00
commit 0d7e3cf916
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,11 +22,10 @@ function buildApi(timeout: number): (args: ApiFetcherArgs) => Promise<{
"X-Client-Version": envConfig.clientVersion,
};
const token = isAuthenticated()
? await getIdToken(getAuthenticatedUser())
: "";
headers["Authorization"] = `Bearer ${token}`;
if (isAuthenticated()) {
const token = await getIdToken(getAuthenticatedUser());
headers["Authorization"] = `Bearer ${token}`;
}
const fetchOptions: RequestInit = {
method: request.method as Method,