kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
useApi: prefer BACKEND_URL, if provided
rodzic
74f74d29fc
commit
fdc03fe610
|
@ -1,6 +1,7 @@
|
|||
import { useMemo } from 'react';
|
||||
|
||||
import { MastodonClient } from 'soapbox/api/MastodonClient';
|
||||
import * as BuildConfig from 'soapbox/build-config';
|
||||
|
||||
import { useAppSelector } from './useAppSelector';
|
||||
import { useOwnAccount } from './useOwnAccount';
|
||||
|
@ -9,7 +10,7 @@ export function useApi(): MastodonClient {
|
|||
const { account } = useOwnAccount();
|
||||
const authUserUrl = useAppSelector((state) => state.auth.me);
|
||||
const accessToken = useAppSelector((state) => account ? state.auth.users.get(account.url)?.access_token : undefined);
|
||||
const baseUrl = new URL(account?.url || authUserUrl || location.origin).origin;
|
||||
const baseUrl = new URL(BuildConfig.BACKEND_URL || account?.url || authUserUrl || location.origin).origin;
|
||||
|
||||
return useMemo(() => {
|
||||
return new MastodonClient(baseUrl, accessToken);
|
||||
|
|
Ładowanie…
Reference in New Issue