fix: use cdn api when querying static CDN files (#4361)

Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com>
This commit is contained in:
X1a0t
2023-09-14 16:56:55 +08:00
committed by GitHub
parent f79cd76cec
commit e1a330a0a6
2 changed files with 8 additions and 4 deletions
@@ -8,13 +8,17 @@ import {
import { fetcher } from '@affine/workspace/affine/gql';
import type { BlobStorage } from '@blocksuite/store';
import { predefinedStaticFiles } from './local-static-storage';
export const createCloudBlobStorage = (workspaceId: string): BlobStorage => {
return {
crud: {
get: async key => {
const suffix = predefinedStaticFiles.includes(key)
? `/static/${key}`
: `/api/workspaces/${workspaceId}/blobs/${key}`;
return fetchWithTraceReport(
runtimeConfig.serverUrlPrefix +
`/api/workspaces/${workspaceId}/blobs/${key}`
runtimeConfig.serverUrlPrefix + suffix
).then(res => {
if (!res.ok) {
// status not in the range 200-299