Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

StorageUnknownError: fetch failed | NestJS #161

@karrtopelka

Description

@karrtopelka

Hello, I am trying to upload an image to existing public bucket

async updateAvatar(file: Express.Multer.File) {
    const { originalname, mimetype, buffer } = file;

    const { data, error } = await this.storage
      .from('avatars')
      .upload(`public/${originalname}`, buffer, {
        contentType: mimetype,
        upsert: false,
      });

    if (error) {
      throw new Error(error.message);
    }

    return data;
  }

But getting error:

{
  data: null,
  error: StorageUnknownError: fetch failed
      at /Users/karrtopelka/Documents/business_idea/proposal/server/node_modules/@supabase/storage-js/src/lib/fetch.ts:32:12
      at Generator.next (<anonymous>)
      at fulfilled (/Users/karrtopelka/Documents/business_idea/proposal/server/node_modules/@supabase/storage-js/dist/main/lib/fetch.js:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5) {
    __isStorageError: true,
    originalError: TypeError: fetch failed
        at Object.fetch (node:internal/deps/undici/undici:14294:11)
        at processTicksAndRejections (node:internal/process/task_queues:95:5) {
      cause: [Error]
    }
  }
}

Here is my service:

import { Injectable } from '@nestjs/common';
import { StorageClient } from '@supabase/storage-js';

@Injectable()
export class SupabaseService extends StorageClient {
  constructor() {
    super(process.env.STORAGE_URL, {
      apikey: process.env.API_SECRET,
      Authorization: `Bearer ${process.env.API_SECRET}`,
    });
  }
}

What can be the issue?
Found unanswered question but with svelte: https://github.com/supabase/supabase/discussions/12389_

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions