1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-11 22:13:32 +00:00

Add 'Accept-Language' header to ApiService requests with value obtained from i18nService

This commit is contained in:
Rui Tome
2024-12-19 15:13:16 +00:00
parent 1d04a0a399
commit 5af754b4d8
2 changed files with 4 additions and 0 deletions

View File

@@ -676,6 +676,7 @@ const safeProviders: SafeProvider[] = [
LogService,
LOGOUT_CALLBACK,
VaultTimeoutSettingsServiceAbstraction,
I18nServiceAbstraction,
],
}),
safeProvider({

View File

@@ -127,6 +127,7 @@ import { ProfileResponse } from "../models/response/profile.response";
import { UserKeyResponse } from "../models/response/user-key.response";
import { AppIdService } from "../platform/abstractions/app-id.service";
import { EnvironmentService } from "../platform/abstractions/environment.service";
import { I18nService } from "../platform/abstractions/i18n.service";
import { LogService } from "../platform/abstractions/log.service";
import { PlatformUtilsService } from "../platform/abstractions/platform-utils.service";
import { flagEnabled } from "../platform/misc/flags";
@@ -168,6 +169,7 @@ export class ApiService implements ApiServiceAbstraction {
private logService: LogService,
private logoutCallback: (logoutReason: LogoutReason) => Promise<void>,
private vaultTimeoutSettingsService: VaultTimeoutSettingsService,
private i18nService: I18nService,
private customUserAgent: string = null,
) {
this.device = platformUtilsService.getDevice();
@@ -1594,6 +1596,7 @@ export class ApiService implements ApiServiceAbstraction {
"Bitwarden-Client-Version",
await this.platformUtilsService.getApplicationVersionNumber(),
);
request.headers.set("Accept-Language", await firstValueFrom(this.i18nService.locale$));
return this.nativeFetch(request);
}