Skip to content

Commit

Permalink
fix: use prefix in electron to prevent formdata bug (#5395)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit authored Dec 25, 2023
1 parent 7fcdb7a commit 555d40c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/frontend/workspace/src/impl/cloud/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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;
Expand Down

0 comments on commit 555d40c

Please sign in to comment.