storage-js: Incorrect storage download link host in local

Describe the bug Local edge functions run on docker inside a container called supabase_deno_relay which auto-sets the SUPABASE_URL. However, it uses the internal URL of the container network. This causes issues with the JS clients that run inside edge functions with storage since it creates the download and signed URLs using the internal http://supabase_kong_hyperion-app:8000 instead of the usual exposed localhost:54321api endpoint.

To Reproduce Steps to reproduce the behavior:

  1. Run edge functions with serve cli command
  2. Generate a download link using the JS client inside an edge function
  3. Try to access the download link (will be in this format: http://supabase_kong_app:8000/storage/v1/object/public/public/users/ce5b2b2f-cfdc-4f56-a886-488dba35a184/file.txt) instead of using localhost:54321

Expected behavior The download link generated is accessible locally using localhost:54321

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • Version of CLI 1.75.2
  • Version of supabase-js 2.26.0

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 6
  • Comments: 16 (2 by maintainers)

Most upvoted comments

This has been causing me nightmares, do I need to start developing in production

Perhaps a simpler alternative is to instantiate a separate StorageClient in your edge function with url set to localhost:54321. For example,

import { StorageClient } from '@supabase/storage-js'

const STORAGE_URL = 'http://localhost:54321/storage/v1'
const SERVICE_KEY = '<service_role_key>'

const storageClient = new StorageClient(STORAGE_URL, {
  apikey: SERVICE_KEY,
  Authorization: `Bearer ${SERVICE_KEY}`,
})

You can use this new client for creating signed urls and the original supabase-js client for other operations that target kong.

what is with this kong issue… I’m just hard coding the URL in my edge function now…

Same over here, I am using the official docker-compose and facing the same issue

Same here!!! even in getting the public URL!

http://kong:8000/storage/v1/object/public/.......

Same issue over here, any updates?

I see, thanks for investigating. Let me transfer this ticket to storage-js to see if anyone can pick it up sooner.

+1, this is smelly 😄