Skip to content

Commit ab70d7a

Browse files
committed
chore: use ofetch for proxy requests
1 parent 61e402d commit ab70d7a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

_nuxthub/server/utils/blob.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { R2Bucket } from '@cloudflare/workers-types/experimental'
2+
import { ofetch } from 'ofetch'
23
import mime from 'mime'
34
// import { imageMeta } from 'image-meta'
45
import type { H3Event } from 'h3'
@@ -35,7 +36,7 @@ export function useBlob () {
3536
return {
3637
async list (options: BlobListOptions = { limit: 1000 }) {
3738
if (proxyURL) {
38-
return $fetch<BlobObject[]>('/api/_hub/blob', {
39+
return ofetch<BlobObject[]>('/api/_hub/blob', {
3940
baseURL: proxyURL,
4041
method: 'GET',
4142
query: options
@@ -68,7 +69,7 @@ export function useBlob () {
6869
async serve (event: H3Event, pathname: string) {
6970
pathname = decodeURI(pathname)
7071
if (proxyURL) {
71-
return $fetch<ReadableStreamDefaultReader<any>>(`/api/_hub/blob/${pathname}`, {
72+
return ofetch<ReadableStreamDefaultReader<any>>(`/api/_hub/blob/${pathname}`, {
7273
baseURL: proxyURL,
7374
method: 'GET'
7475
})
@@ -92,7 +93,7 @@ export function useBlob () {
9293
const headers: Record<string, string> = {}
9394
if (contentType) { headers['content-type'] = contentType }
9495
if (contentLength) { headers['content-length'] = contentLength }
95-
return await $fetch<BlobObject>(joinURL('/api/_hub/blob', pathname), {
96+
return await ofetch<BlobObject>(joinURL('/api/_hub/blob', pathname), {
9697
baseURL: proxyURL,
9798
method: 'PUT',
9899
headers,
@@ -121,7 +122,7 @@ export function useBlob () {
121122
async head (pathname: string) {
122123
pathname = decodeURI(pathname)
123124
if (proxyURL) {
124-
const { headers } = await $fetch.raw<void>(joinURL('/api/_hub/blob', pathname), {
125+
const { headers } = await ofetch.raw<void>(joinURL('/api/_hub/blob', pathname), {
125126
baseURL: proxyURL,
126127
method: 'HEAD'
127128
})
@@ -139,7 +140,7 @@ export function useBlob () {
139140
async delete (pathname: string) {
140141
pathname = decodeURI(pathname)
141142
if (proxyURL) {
142-
await $fetch<void>(`/api/_hub/blob/${pathname}`, {
143+
await ofetch<void>(`/api/_hub/blob/${pathname}`, {
143144
baseURL: proxyURL,
144145
method: 'DELETE',
145146
})

0 commit comments

Comments
 (0)