[solved] CORS error in a request to Supabase Storage
Guilherme Hirsch
2 years ago
Hey guys! I copied the application template with the request to upload a file to Supabase Storage. I changed it to my account data, but a CORS error appears in the console, can anyone help me with this?
✅1
👍1
gazinhio
2 years ago
Did you tick the Proxy box on the API in the bottom-right of the API set-up? (think it's ticked it by default now). This proxies the call through Toddle's secure server. If not, the call is made through the client/browser and often results in a CORS error as the server doesn't trust the origin of the call.
🥳1
Guilherme Hirsch
2 years ago
Excellent! Now the error message is different:
Can you tell me if anything has changed in the Supabase documentation regarding this?
Stockton
2 years ago
Looks like you have a space before storage in the path
Nvm maybe not
Guilherme Hirsch
2 years ago
I believe this is not the problem. I put it as POST now and it still has an error.
In the template it was as PUT the request
Lucas G
2 years ago
I haven't used the template but it is possible that some changes have happened to the API since it was made.
I need to work on supabase uploads soon too so I'll try it out as well and report back
Lucas G
2 years ago
Just quickly looking at it, it might be missing the bucket and filename /paths/
Lucas G
2 years ago
Something else I saw a while back: In the request URL https://{ref}.supabase.co/storage/v1/object/{bucket}/{filename.ext} you can actually set {filename.ext} to any filename with extension that you want to use to save the file server-side. It does not have to be the same as the file's local filename.
Policies should be whatever you need them to be. Allow anon if it's meant to be a public bucket otherwise it should verify users the same as your other tables
Lucas G
1 year ago
Enter your policies in the 'Storage' options in the Supabase backend, right under where you create the bucket
Normally, you add them to the 'Objects' field
asad
1 year ago
@Lucas G is there in any tutorial on the Supabase Upload Input i can't figure it out
Did the component send anything back in the event?
Lucas G
1 year ago
It was an RLS issue why the upload wasn't working ^
unicodes
1 year ago
@Lucas G I get the error CORS, and it is very strange because everything is identic with avatar, but for avatar works and for covers doesn't. Do you have any ideea why it doesn't work if everything is identic avatar = covers? https://discord.com/channels/972416966683926538/1284793988758376458
unicodes
1 year ago
I'm full o policies, but still receiving the CORS error.