mirror of
https://github.com/logto-io/logto.git
synced 2025-03-17 22:31:28 -05:00
refactor(console): update admin endpoint pattern (#3605)
This commit is contained in:
parent
619e1b76a6
commit
e87ff837cd
4 changed files with 14 additions and 9 deletions
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
|
@ -132,7 +132,6 @@ jobs:
|
|||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
admin_endpoint=https://auth.logto.${{ inputs.target == 'prod' && 'io' || 'dev' }}/
|
||||
applicationinsights_connection_string=${{ (inputs.target || 'dev') == 'dev' && secrets.APPLICATIONINSIGHTS_CONNECTION_STRING || secrets.APPLICATIONINSIGHTS_CONNECTION_STRING_PROD }}
|
||||
|
||||
deploy-core:
|
||||
|
|
|
@ -21,8 +21,6 @@ RUN pnpm i
|
|||
# Admin Console build env
|
||||
ENV CONSOLE_PUBLIC_URL=/
|
||||
ENV IS_CLOUD=1
|
||||
ARG admin_endpoint
|
||||
ENV ADMIN_ENDPOINT=${admin_endpoint}
|
||||
ARG applicationinsights_connection_string
|
||||
ENV APPLICATIONINSIGHTS_CONNECTION_STRING=${applicationinsights_connection_string}
|
||||
RUN pnpm prepack
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { generateStandardId } from '@logto/core-kit';
|
||||
import { cloudApiIndicator } from '@logto/schemas';
|
||||
import { GlobalValues } from '@logto/shared';
|
||||
import { appendPath } from '@silverhand/essentials';
|
||||
|
||||
export const createCloudServiceConnector = (data: {
|
||||
tenantId: string;
|
||||
|
@ -19,8 +20,8 @@ export const createCloudServiceConnector = (data: {
|
|||
config: {
|
||||
appId,
|
||||
appSecret,
|
||||
tokenEndpoint: `${adminUrlSet.endpoint.toString()}oidc/token`,
|
||||
endpoint: `${cloudUrlSet.endpoint.toString()}api`,
|
||||
tokenEndpoint: appendPath(adminUrlSet.endpoint, 'oidc/token').toString(),
|
||||
endpoint: appendPath(cloudUrlSet.endpoint, 'api').toString(),
|
||||
resource: cloudApiIndicator,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -4,11 +4,18 @@ import { CloudRoute } from '@/cloud/types';
|
|||
|
||||
import { isCloud } from './cloud';
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const getAdminTenantEndpoint = () => {
|
||||
// Allow endpoint override for dev or testing
|
||||
if (process.env.ADMIN_ENDPOINT) {
|
||||
return new URL(process.env.ADMIN_ENDPOINT);
|
||||
}
|
||||
|
||||
export const adminTenantEndpoint = new URL(
|
||||
process.env.ADMIN_ENDPOINT ?? (isProduction ? window.location.origin : 'http://localhost:3002')
|
||||
);
|
||||
return new URL(
|
||||
isCloud ? window.location.origin.replace('cloud.', 'auth.') : window.location.origin
|
||||
);
|
||||
};
|
||||
|
||||
export const adminTenantEndpoint = getAdminTenantEndpoint();
|
||||
|
||||
export const getUserTenantId = () => {
|
||||
if (isCloud) {
|
||||
|
|
Loading…
Add table
Reference in a new issue