@@ -60,7 +60,7 @@ export const useCloudApi = ({ hideErrorToast = false }: UseCloudApiProps = {}):
6060 ...conditional ( ! hideErrorToast && { error : toastResponseError } ) ,
6161 } ,
6262 } ) ,
63- [ getAccessToken , hideErrorToast , isAuthenticated ]
63+ [ getAccessToken , hideErrorToast , i18n . language , isAuthenticated ]
6464 ) ;
6565
6666 return api ;
@@ -69,14 +69,16 @@ export const useCloudApi = ({ hideErrorToast = false }: UseCloudApiProps = {}):
6969type CreateTenantOptions = UseCloudApiProps &
7070 Pick < ReturnType < typeof useLogto > , 'isAuthenticated' | 'getOrganizationToken' > & {
7171 tenantId : string ;
72+ language : string ;
7273 } ;
7374
7475export const createTenantApi = ( {
7576 hideErrorToast = false ,
7677 isAuthenticated,
7778 getOrganizationToken,
7879 tenantId,
79- } : CreateTenantOptions ) =>
80+ language,
81+ } : CreateTenantOptions ) : Client < typeof tenantAuthRouter > =>
8082 new Client < typeof tenantAuthRouter > ( {
8183 baseUrl : window . location . origin ,
8284 headers : async ( ) => {
@@ -85,6 +87,7 @@ export const createTenantApi = ({
8587 Authorization : `Bearer ${
8688 ( await getOrganizationToken ( getTenantOrganizationId ( tenantId ) ) ) ?? ''
8789 } `,
90+ 'Accept-Language' : language ,
8891 } ;
8992 }
9093 } ,
@@ -99,6 +102,7 @@ export const createTenantApi = ({
99102export const useAuthedCloudApi = ( { hideErrorToast = false } : UseCloudApiProps = { } ) : Client <
100103 typeof tenantAuthRouter
101104> => {
105+ const { i18n } = useTranslation ( ) ;
102106 const { currentTenantId } = useContext ( TenantsContext ) ;
103107 const { isAuthenticated, getOrganizationToken } = useLogto ( ) ;
104108 const api = useMemo (
@@ -108,8 +112,9 @@ export const useAuthedCloudApi = ({ hideErrorToast = false }: UseCloudApiProps =
108112 isAuthenticated,
109113 getOrganizationToken,
110114 tenantId : currentTenantId ,
115+ language : i18n . language ,
111116 } ) ,
112- [ currentTenantId , getOrganizationToken , hideErrorToast , isAuthenticated ]
117+ [ currentTenantId , getOrganizationToken , hideErrorToast , isAuthenticated , i18n . language ]
113118 ) ;
114119
115120 return api ;
0 commit comments