mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
feat: add is-valid-ip-address (#1591)
This commit is contained in:
@@ -6,14 +6,21 @@ import {
|
||||
} from '@affine/datacenter';
|
||||
import { config } from '@affine/env';
|
||||
|
||||
import { isValidIPAddress } from '../utils/is-valid-ip-address';
|
||||
|
||||
let prefixUrl = '/';
|
||||
if (typeof window === 'undefined') {
|
||||
// SSR
|
||||
if (config.serverAPI.startsWith('100')) {
|
||||
const serverAPI = config.serverAPI;
|
||||
if (isValidIPAddress(serverAPI)) {
|
||||
// This is for Server side rendering support
|
||||
prefixUrl = new URL('http://' + config.serverAPI + '/').origin;
|
||||
} else {
|
||||
console.warn('serverAPI is not a valid URL', config.serverAPI);
|
||||
try {
|
||||
new URL(serverAPI);
|
||||
} catch (e) {
|
||||
console.warn('serverAPI is not a valid URL', config.serverAPI);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
Reference in New Issue
Block a user