diff --git a/src/runtime/server/api/_hub/blob/[...pathname].head.ts b/src/runtime/server/api/_hub/blob/[...pathname].head.ts deleted file mode 100644 index 2ce5fae9..00000000 --- a/src/runtime/server/api/_hub/blob/[...pathname].head.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { eventHandler, getValidatedRouterParams, setHeader, sendNoContent } from 'h3' -import { z } from 'zod' -import { hubBlob } from '../../../utils/blob' - -export default eventHandler(async (event) => { - const { pathname } = await getValidatedRouterParams(event, z.object({ - pathname: z.string().min(1) - }).parse) - - const blob = await hubBlob().head(pathname) - - setHeader(event, 'x-blob', JSON.stringify(blob)) - - return sendNoContent(event) -}) diff --git a/src/runtime/server/api/_hub/blob/head/[...pathname].get.ts b/src/runtime/server/api/_hub/blob/head/[...pathname].get.ts new file mode 100644 index 00000000..a8b87682 --- /dev/null +++ b/src/runtime/server/api/_hub/blob/head/[...pathname].get.ts @@ -0,0 +1,11 @@ +import { eventHandler, getValidatedRouterParams } from 'h3' +import { z } from 'zod' +import { hubBlob } from '../../../../utils/blob' + +export default eventHandler(async (event) => { + const { pathname } = await getValidatedRouterParams(event, z.object({ + pathname: z.string().min(1) + }).parse) + + return hubBlob().head(pathname) +}) diff --git a/src/runtime/server/utils/blob.ts b/src/runtime/server/utils/blob.ts index 81298ff1..932d5b27 100644 --- a/src/runtime/server/utils/blob.ts +++ b/src/runtime/server/utils/blob.ts @@ -269,10 +269,9 @@ export function proxyHubBlob(projectUrl: string, secretKey?: string) { }) }, async head(pathname: string) { - const { headers } = await blobAPI.raw(decodeURI(pathname), { - method: 'HEAD' + return await blobAPI(`/head/${decodeURI(pathname)}`, { + method: 'GET' }) - return JSON.parse(headers.get('x-blob') || '{}') as BlobObject }, async del(pathnames: string | string[]) { if (Array.isArray(pathnames)) {