Unable to CreateClient due to invalid Project Url
I am creating a upload service where I am using multer and supabase with expressJs.
While creating supabase client its throwing the
invalid_url
error and adding /auth/v1
to url (weird?)
Unable to fix it for hour now
imageController - https://pastecord.com/yzevytaquj.typescript
StorageClient - https://pastecord.com/fudinyzupe.typescript37 Replies
The dashboard is showing the same url used in my env file but its not accesible through browser
Logout your config.PROJECT_URL in your createClient code.
it was correct
currently I switch it to use storage client directly through supabase/storage package and it seems to work
Why does supabse add extra string to url?
I am trying to upload the image and get the data and its throwing this error
code - https://pastecord.com/pybigupebo.typescript
@garyaustin I am using unix time to create storagepath, using the same structure defined in the docs.
https://supabase.com/docs/reference/javascript/storage-from-upload
JavaScript: Upload a file | Supabase Docs
Supabase API reference for JavaScript: Upload a file
the same thing was happening with createClient but for now I fixed it using storage library and creating it directly
Supabase initiated with the base url in supabase-js will not add anything to the url. Then each component (auth/storage/postgrest) adds it's bit of url like /storage/v1. After that the file name gets added.
Your code above looks like you are hand setting the storage url to
"https:// evaxcywvwsgcqknqtckv.supabase.co/";/object
. The storage then adds your path /images/blah.jbp to it.
Very few use storage.js/auth.js/postgres.js directly.but I am not
this is the console.log response
project_url is https://evaxcywvwsgcqknqtckv.supabase.co/
from config file
No one is reporting bugs with the js client and it would be major if it was.
You are most likely doing something wrong in setting it up, or passing the client around if you are doing serverside stuff.
the whole code where client is used is there and I can't really find the bug in that one
and the last one where client variable is used is config file
which is giving a correct output
I have no idea what multer is and don't use express.js. But if you pass supabase-js the correct project then it will work for all components.
ok i'll try to fix it
If you have multiple createClients for different server components (as you are doing Express) maybe your clients are not getting the initialization pass around.
If your storage call url you show is real, then somewhere the storage.url got set the string clip I showed, including the quotes which looks like bad code to me or somehow a string being double quoted.
yeah the string is getting quoted somewhere in between
Oh the object is part of the storage adding it. So it is just the string is being double quoted. The semicolon in the string is odd too.
yeah
And seems to be from client code.
client is just a postman request with the image and content-type
I meant your code setting up supabase, not the browser client.
this is supabase setup, can't see anything odd here.
storage client does not take supabaseUrl.
It has to have /storage/v1 added on to it.
oh right
As I said very few deal with the sub REST clients directly.
Maybe your config as double quotes around it and it shouldn't.
what do you mean by this
Almost everyone uses supabase-js, not storage-js/auth-js/realtime-js/postgrest-js.
process.env.PROJECT_URL; Maybe that has double quotes around it.
there are no downside with using them standalone right?
It is much hard for some of them.
Storage is fairly clean, but like you entered the Authorization header, maybe that works, I've not looked.
Just saying docs are not great on them and hardly anyone I've helped uses them.
ok I see. Thanks 👍
Find your extra double quote and then add /storage/v1 and that should solve your storage client url issue.
sure
Some configs/env files don't need quotes around strings I believe.

hmm but I believe dotenv trim the quotes
not sure
Supabase does not add them...
supabase doesn't add env var with strings?
supabase will not add double quotes to the url you provide.
The few examples I see don't have quotes for expressjs env file.

yeah I get that as they are URL object, not sure which part is stringifying the url. Not using quoted url this time.
Let me find this bug on my won
own*
Fixed : By just saving the file and reloading. Not sure why, maybe cached.