mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 23:56:36 +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;
|
||||
|
||||
// this is for the electron app
|
||||
/**
|
||||
* @deprecated need to be refactored
|
||||
*/
|
||||
serverUrlPrefix: string;
|
||||
appVersion: string;
|
||||
editorVersion: string;
|
||||
|
||||
@@ -3,20 +3,31 @@ import { apis } from '@affine/electron-api';
|
||||
|
||||
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) {
|
||||
target = /^https?:\/\//.test(target)
|
||||
? target
|
||||
: BUILD_CONFIG.serverUrlPrefix + target;
|
||||
const isFullUrl = /^https?:\/\//.test(target);
|
||||
|
||||
const redirectProxy = origin + '/redirect-proxy';
|
||||
target = isFullUrl ? target : origin + target;
|
||||
|
||||
const targetUrl = new URL(target);
|
||||
|
||||
let url: string;
|
||||
// safe to open directly if in the same origin
|
||||
if (targetUrl.origin === location.origin) {
|
||||
if (targetUrl.origin === origin) {
|
||||
url = target;
|
||||
} else {
|
||||
const builder = new URL(BUILD_CONFIG.serverUrlPrefix + '/redirect-proxy');
|
||||
builder.searchParams.set('redirect_uri', target);
|
||||
url = builder.toString();
|
||||
const search = new URLSearchParams({
|
||||
redirect_uri: target,
|
||||
});
|
||||
|
||||
url = `${redirectProxy}?${search.toString()}`;
|
||||
}
|
||||
|
||||
if (BUILD_CONFIG.isElectron) {
|
||||
|
||||
Reference in New Issue
Block a user