#R2 objects giving 404 unless I use double-slash after my hostname

21 messages · Page 1 of 1 (latest)

rotund marsh
#

Okay so, whenever I try accessing objects through my custom domain (say cdn.example.com), they're all giving me a 404 error. I access them like this: https://cdn.example.com/object
I then decided to check the objects on the control panel. There was a list of urls (my domain and the S3 API domain) and they all had a double slash after the hostname. Because of this, I tried accessing my object like this: https://cdn.example.com//object and that actually worked.
Any ideas on how to fix this so I can access objects with just a single slash (as URLs are supposed to be)?

hybrid gale
#

Do you write your objects with a slash at the start of them? I would assume you are given that would be the only way the url would start with // remove the / from the start of your object key and you should be good

rotund marsh
#

I tried uploading an object through the panel as well, didn't work either

#

although I did upload it in a folder, so if the folder as a whole is messed up then that would explain it

#

oh that explains it

#

huh that's strange, I put a log statement to see what I'm sending to my AWS library as the Key and it doesn't even have a leading slash

clever atlas
#

it looks like there's an object called / and that's what's causing the cdn.domain.com//

rotund marsh
clever atlas
#

accidental creation?

#

just wipe it and upload something new right there, then test

#

unless there's stuff in it

rotund marsh
#

either way i'm waiting for docker hub to go back up so I can redeploy my backend with the R2 credentials and reupload my files

#

also yes, uploading a file to the root works fine so it's probably something to do with the lib

rotund marsh
#

is there any way to mass-delete objects?

#

also yeah for some weird reason everything gets pushed to that / object and idk why

#

my keys don't even start with / when I give them to the library

#

wait I think I know what's going on

#

I'm using path.join to generate my paths and I feel like on windows it doesn't add a leading slash but on linux it does

rotund marsh
#

yep I just made a sanitization function and used it to remove the leading slash

#

it work fine now