mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 15:39:24 +08:00
fix: get api url (#4020)
This commit is contained in:
parent
beab81818f
commit
e1533ec800
@ -167,6 +167,15 @@ export class Application {
|
||||
return this.options.publicPath || '/';
|
||||
}
|
||||
|
||||
getApiUrl(pathname = '') {
|
||||
let baseURL = this.apiClient.axios['defaults']['baseURL'];
|
||||
if (!baseURL.startsWith('http://') || !baseURL.startsWith('https://')) {
|
||||
const { protocol, host } = window.location;
|
||||
baseURL = `${protocol}//${host}/`;
|
||||
}
|
||||
return baseURL + pathname;
|
||||
}
|
||||
|
||||
getRouteUrl(pathname: string) {
|
||||
return this.options.publicPath.replace(/\/$/g, '') + pathname;
|
||||
}
|
||||
|
@ -41,8 +41,7 @@ export class WebSocketClient {
|
||||
if (!this.app) {
|
||||
return;
|
||||
}
|
||||
const options = this.app.getOptions();
|
||||
const apiBaseURL = options?.apiClient?.['baseURL'];
|
||||
const apiBaseURL = this.app.getApiUrl();
|
||||
if (!apiBaseURL) {
|
||||
return;
|
||||
}
|
||||
|
@ -26,9 +26,7 @@ export const Iframe: any = observer(
|
||||
|
||||
const src = React.useMemo(() => {
|
||||
if (mode === 'html') {
|
||||
const options = app.getOptions();
|
||||
const apiBaseURL: string = options?.apiClient?.['baseURL'];
|
||||
return `${apiBaseURL}iframeHtml:getHtml/${htmlId}?token=${api.auth.getToken()}&v=${field.data?.v || ''}`;
|
||||
return app.getApiUrl(`iframeHtml:getHtml/${htmlId}?token=${api.auth.getToken()}&v=${field.data?.v || ''}`);
|
||||
}
|
||||
return url;
|
||||
}, [app, url, mode, htmlId, field.data?.v]);
|
||||
|
@ -330,12 +330,7 @@ const Usage = observer(
|
||||
const app = useApp();
|
||||
|
||||
const url = useMemo(() => {
|
||||
const options = app.getOptions();
|
||||
const apiBaseURL: string = options?.apiClient?.['baseURL'];
|
||||
const { protocol, host } = window.location;
|
||||
return apiBaseURL.startsWith('http')
|
||||
? `${apiBaseURL}oidc:redirect`
|
||||
: `${protocol}//${host}${apiBaseURL}oidc:redirect`;
|
||||
return app.getApiUrl('oidc:redirect');
|
||||
}, [app]);
|
||||
|
||||
const copy = (text: string) => {
|
||||
|
@ -77,14 +77,8 @@ const Usage = observer(
|
||||
const name = form.values.name ?? record.name;
|
||||
|
||||
const url = useMemo(() => {
|
||||
const options = app.getOptions();
|
||||
const apiBaseURL: string = options?.apiClient?.['baseURL'];
|
||||
const { protocol, host } = window.location;
|
||||
const appName = getSubAppName(app.getPublicPath()) || 'main';
|
||||
|
||||
return apiBaseURL.startsWith('http')
|
||||
? `${apiBaseURL}saml:redirect?authenticator=${name}&__appName=${appName}`
|
||||
: `${protocol}//${host}${apiBaseURL}saml:redirect?authenticator=${name}&__appName=${appName}`;
|
||||
return app.getApiUrl(`saml:redirect?authenticator=${name}&__appName=${appName}`);
|
||||
}, [app, name]);
|
||||
|
||||
const copy = (text: string) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user