Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public URLs for storage in local development doesn't work #5637

Closed
statico opened this issue Feb 23, 2022 · 2 comments
Closed

Public URLs for storage in local development doesn't work #5637

statico opened this issue Feb 23, 2022 · 2 comments
Labels
bug Something isn't working p4 Priority 4

Comments

@statico
Copy link

statico commented Feb 23, 2022

Bug report

Describe the bug

It appears that, when using local development with supabase start, supabase.storage.from().getPublicUrl() doesn't seem to return a valid URL. However, .download() works fine.

To Reproduce

  1. Start Supabase locally with supabase start
  2. Upload an image with supabase.storage.from("test").upload(path, file) (I guess you don't need to initialize buckets locally? There's nothing in the web interface)
  3. Try supabase.storage.from("test").download(path) -- you'll get valid data
  4. Try supabase.storage.from("test").getPublicUrl(path) -- you'll get a URL like http://localhost:54321/storage/v1/object/public/test/0.33763726009346384.jpg but that returns a 404 with {"statusCode":"404","error":"Not found","message":"The resource was not found"}

Expected behavior

I would expect the URL from getPublicURL() to return a 200 with the image.

Screenshots

n/a

System information

  • OS: macOS 12.2
  • Browser: Chrome latest
  • Version of supabase-js: 0.18.1
  • Version of Node.js: v16.13.0
@statico statico added the bug Something isn't working label Feb 23, 2022
@inian
Copy link
Member

inian commented Feb 24, 2022

Hmm I do see that the upload code doenst check if the bucket exists first, will create an issue for this. If you create a bucket first and set the bucket to public, getPublicURL should then work. Buckets are private by default (and in this weird case where the bucket doesn't actually exist, the code assumes its a private bucket)

@vbylen
Copy link

vbylen commented Jun 1, 2022

@inian how would I make this a public bucket using the SQL below?

insert into storage.buckets (id, name)
values ('avatars', 'avatars');

edit: here is the solution

insert into storage.buckets (id, name, public)
values ('avatars', 'avatars', true);

@egor-romanov egor-romanov added the p4 Priority 4 label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p4 Priority 4
Projects
None yet
Development

No branches or pull requests

4 participants