From 70ab3b491659130790a998a0fd36f4bc80583912 Mon Sep 17 00:00:00 2001 From: DarkSky <25152247+darkskygit@users.noreply.github.com> Date: Mon, 25 Dec 2023 23:14:08 +0800 Subject: [PATCH] fix: use prefix in electron to prevent formdata bug (#5395) --- packages/frontend/workspace/src/impl/cloud/blob.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/frontend/workspace/src/impl/cloud/blob.ts b/packages/frontend/workspace/src/impl/cloud/blob.ts index 824eb9f31f..20eb5f259a 100644 --- a/packages/frontend/workspace/src/impl/cloud/blob.ts +++ b/packages/frontend/workspace/src/impl/cloud/blob.ts @@ -10,6 +10,14 @@ import { fetcher } from '../../affine/gql'; import type { BlobStorage } from '../../engine/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 = ( workspaceId: string ): BlobStorage => { @@ -21,7 +29,7 @@ export const createAffineCloudBlobStorage = ( ? key : `/api/workspaces/${workspaceId}/blobs/${key}`; - return fetchWithTraceReport(suffix).then(async res => { + return fetchWithTraceReport(getBaseUrl() + suffix).then(async res => { if (!res.ok) { // status not in the range 200-299 return null;