Fix useApi auth URL
This commit is contained in:
parent
ba4ab3d39a
commit
0396cb1aef
|
@ -7,8 +7,9 @@ import { useOwnAccount } from './useOwnAccount';
|
||||||
|
|
||||||
export function useApi(): MastodonClient {
|
export function useApi(): MastodonClient {
|
||||||
const { account } = useOwnAccount();
|
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 accessToken = useAppSelector((state) => account ? state.auth.users.get(account.url)?.access_token : undefined);
|
||||||
const baseUrl = account ? new URL(account.url).origin : location.origin;
|
const baseUrl = new URL(account?.url || authUserUrl || location.origin).origin;
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
return new MastodonClient(baseUrl, accessToken);
|
return new MastodonClient(baseUrl, accessToken);
|
||||||
|
|
Loading…
Reference in New Issue