app: fix auth entry point redirect
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -28,9 +28,20 @@ import {
|
||||
configApiRef,
|
||||
createApiFactory,
|
||||
discoveryApiRef,
|
||||
useApi,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { AuthProxyDiscoveryApi } from '../src/AuthProxyDiscoveryApi';
|
||||
|
||||
// TODO(Rugvip): make this available via some util, or maybe Utility API?
|
||||
function readBasePath(configApi: typeof configApiRef.T) {
|
||||
let { pathname } = new URL(
|
||||
configApi.getOptionalString('app.baseUrl') ?? '/',
|
||||
'http://sample.dev', // baseUrl can be specified as just a path
|
||||
);
|
||||
pathname = pathname.replace(/\/*$/, '');
|
||||
return pathname;
|
||||
}
|
||||
|
||||
const app = createApp({
|
||||
apis: [
|
||||
createApiFactory({
|
||||
@@ -54,7 +65,7 @@ const app = createApp({
|
||||
});
|
||||
|
||||
function RedirectToRoot() {
|
||||
window.location.pathname += '/..';
|
||||
window.location.pathname = readBasePath(useApi(configApiRef));
|
||||
return <div />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user