fix: use absolute path in gql client (#5454)
This commit is contained in:
@@ -2,8 +2,19 @@ export * from './fetcher';
|
|||||||
export * from './graphql';
|
export * from './graphql';
|
||||||
export * from './schema';
|
export * from './schema';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
import '@affine/env/global';
|
|
||||||
|
import { setupGlobal } from '@affine/env/global';
|
||||||
|
|
||||||
import { gqlFetcherFactory } from './fetcher';
|
import { gqlFetcherFactory } from './fetcher';
|
||||||
|
|
||||||
export const fetcher = gqlFetcherFactory('/graphql');
|
setupGlobal();
|
||||||
|
|
||||||
|
export function getBaseUrl(): string {
|
||||||
|
if (environment.isDesktop) {
|
||||||
|
return runtimeConfig.serverUrlPrefix;
|
||||||
|
}
|
||||||
|
const { protocol, hostname, port } = window.location;
|
||||||
|
return `${protocol}//${hostname}${port ? `:${port}` : ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const fetcher = gqlFetcherFactory(getBaseUrl() + '/graphql');
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
checkBlobSizesQuery,
|
checkBlobSizesQuery,
|
||||||
deleteBlobMutation,
|
deleteBlobMutation,
|
||||||
fetchWithTraceReport,
|
fetchWithTraceReport,
|
||||||
|
getBaseUrl,
|
||||||
listBlobsQuery,
|
listBlobsQuery,
|
||||||
setBlobMutation,
|
setBlobMutation,
|
||||||
} from '@affine/graphql';
|
} from '@affine/graphql';
|
||||||
@@ -10,14 +11,6 @@ import { fetcher } from '@affine/graphql';
|
|||||||
import type { BlobStorage } from '../../engine/blob';
|
import type { BlobStorage } from '../../engine/blob';
|
||||||
import { bufferToBlob } from '../../utils/buffer-to-blob';
|
import { bufferToBlob } from '../../utils/buffer-to-blob';
|
||||||
|
|
||||||
function getBaseUrl(): string {
|
|
||||||
if (environment.isDesktop) {
|
|
||||||
return runtimeConfig.serverUrlPrefix;
|
|
||||||
}
|
|
||||||
const { protocol, hostname, port } = window.location;
|
|
||||||
return `${protocol}//${hostname}${port ? `:${port}` : ''}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createAffineCloudBlobStorage = (
|
export const createAffineCloudBlobStorage = (
|
||||||
workspaceId: string
|
workspaceId: string
|
||||||
): BlobStorage => {
|
): BlobStorage => {
|
||||||
|
|||||||
Reference in New Issue
Block a user