mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
fix(core): avoid using serverUrlPrefix config (#8448)
This commit is contained in:
Vendored
+3
@@ -17,6 +17,9 @@ export type BUILD_CONFIG_TYPE = {
|
|||||||
isMobileWeb: boolean;
|
isMobileWeb: boolean;
|
||||||
|
|
||||||
// this is for the electron app
|
// this is for the electron app
|
||||||
|
/**
|
||||||
|
* @deprecated need to be refactored
|
||||||
|
*/
|
||||||
serverUrlPrefix: string;
|
serverUrlPrefix: string;
|
||||||
appVersion: string;
|
appVersion: string;
|
||||||
editorVersion: string;
|
editorVersion: string;
|
||||||
|
|||||||
@@ -3,20 +3,31 @@ import { apis } from '@affine/electron-api';
|
|||||||
|
|
||||||
const logger = new DebugLogger('popup');
|
const logger = new DebugLogger('popup');
|
||||||
|
|
||||||
|
const origin = BUILD_CONFIG.isElectron
|
||||||
|
? BUILD_CONFIG.serverUrlPrefix
|
||||||
|
: location.origin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated need to be refactored as [UrlService] dependencies on [ServerConfigService]
|
||||||
|
*/
|
||||||
export function popupWindow(target: string) {
|
export function popupWindow(target: string) {
|
||||||
target = /^https?:\/\//.test(target)
|
const isFullUrl = /^https?:\/\//.test(target);
|
||||||
? target
|
|
||||||
: BUILD_CONFIG.serverUrlPrefix + target;
|
const redirectProxy = origin + '/redirect-proxy';
|
||||||
|
target = isFullUrl ? target : origin + target;
|
||||||
|
|
||||||
const targetUrl = new URL(target);
|
const targetUrl = new URL(target);
|
||||||
|
|
||||||
let url: string;
|
let url: string;
|
||||||
// safe to open directly if in the same origin
|
// safe to open directly if in the same origin
|
||||||
if (targetUrl.origin === location.origin) {
|
if (targetUrl.origin === origin) {
|
||||||
url = target;
|
url = target;
|
||||||
} else {
|
} else {
|
||||||
const builder = new URL(BUILD_CONFIG.serverUrlPrefix + '/redirect-proxy');
|
const search = new URLSearchParams({
|
||||||
builder.searchParams.set('redirect_uri', target);
|
redirect_uri: target,
|
||||||
url = builder.toString();
|
});
|
||||||
|
|
||||||
|
url = `${redirectProxy}?${search.toString()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BUILD_CONFIG.isElectron) {
|
if (BUILD_CONFIG.isElectron) {
|
||||||
|
|||||||
Reference in New Issue
Block a user