mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
25 lines
602 B
TypeScript
25 lines
602 B
TypeScript
export * from './error';
|
|
export * from './fetcher';
|
|
export * from './graphql';
|
|
export * from './schema';
|
|
|
|
import { setupGlobal } from '@affine/env/global';
|
|
|
|
import { gqlFetcherFactory } from './fetcher';
|
|
|
|
setupGlobal();
|
|
|
|
export function getBaseUrl(): string {
|
|
if (environment.isDesktop) {
|
|
return runtimeConfig.serverUrlPrefix;
|
|
}
|
|
if (typeof window === 'undefined') {
|
|
// is nodejs
|
|
return '';
|
|
}
|
|
const { protocol, hostname, port } = window.location;
|
|
return `${protocol}//${hostname}${port ? `:${port}` : ''}`;
|
|
}
|
|
|
|
export const fetcher = gqlFetcherFactory(getBaseUrl() + '/graphql');
|