Merge branch 'baseurl' into 'main'
Fix baseURL drama See merge request soapbox-pub/soapbox!3299
This commit is contained in:
commit
98617d1036
|
@ -33,7 +33,7 @@ const fetchFrontendConfigurations = () =>
|
|||
(dispatch: AppDispatch, getState: () => RootState) =>
|
||||
api(getState)
|
||||
.get('/api/pleroma/frontend_configurations')
|
||||
.then((response) => response.json()).then((data) => data);
|
||||
.then((response) => response.json());
|
||||
|
||||
/** Conditionally fetches Soapbox config depending on backend features */
|
||||
const fetchSoapboxConfig = (host: string | null = null) =>
|
||||
|
@ -41,7 +41,7 @@ const fetchSoapboxConfig = (host: string | null = null) =>
|
|||
const features = getFeatures(getState().instance);
|
||||
|
||||
if (features.frontendConfigurations) {
|
||||
return dispatch(fetchFrontendConfigurations()).then(data => {
|
||||
return dispatch(fetchFrontendConfigurations()).then((data) => {
|
||||
if (data.soapbox_fe) {
|
||||
dispatch(importSoapboxConfig(data.soapbox_fe, host));
|
||||
return data.soapbox_fe;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { createSelector } from 'reselect';
|
||||
|
||||
import { MastodonClient } from 'soapbox/api/MastodonClient.ts';
|
||||
import * as BuildConfig from 'soapbox/build-config.ts';
|
||||
import { selectAccount } from 'soapbox/selectors/index.ts';
|
||||
import { RootState } from 'soapbox/store.ts';
|
||||
import { getAccessToken, getAppToken, parseBaseURL } from 'soapbox/utils/auth.ts';
|
||||
|
@ -13,14 +14,13 @@ const getAuthBaseURL = createSelector([
|
|||
(state: RootState, me: string | false | null) => me ? selectAccount(state, me)?.url : undefined,
|
||||
(state: RootState, _me: string | false | null) => state.auth.me,
|
||||
], (accountUrl, authUserUrl) => {
|
||||
const baseURL = parseBaseURL(accountUrl) || parseBaseURL(authUserUrl);
|
||||
return baseURL !== window.location.origin ? baseURL : '';
|
||||
return parseBaseURL(accountUrl) || parseBaseURL(authUserUrl);
|
||||
});
|
||||
|
||||
/** Base client for HTTP requests. */
|
||||
export const baseClient = (
|
||||
accessToken?: string | null,
|
||||
baseURL: string = '',
|
||||
baseURL: string = location.origin,
|
||||
): MastodonClient => {
|
||||
return new MastodonClient(baseURL, accessToken || undefined);
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ export default (getState: () => RootState, authType: string = 'user'): MastodonC
|
|||
const state = getState();
|
||||
const accessToken = getToken(state, authType);
|
||||
const me = state.me;
|
||||
const baseURL = me ? getAuthBaseURL(state, me) : '';
|
||||
const baseURL = BuildConfig.BACKEND_URL ?? (me ? getAuthBaseURL(state, me) : location.origin);
|
||||
|
||||
return baseClient(accessToken, baseURL);
|
||||
};
|
||||
|
|
|
@ -75,7 +75,8 @@ const SoapboxLoad: React.FC<ISoapboxLoad> = ({ children }) => {
|
|||
if (!instance.isLoading && !nostrLoading) {
|
||||
dispatch(loadInitial()).then(() => {
|
||||
setIsLoaded(true);
|
||||
}).catch(() => {
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
setIsLoaded(true);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue