R2.dev subdomain has been set to 'allow' status. But when open the link, it showed Error 404.
"Error 404
This object could not be viewed
You are not authorized to view this object
This object does not exist or is not publicly accessible at this URL. Check the URL of the object that you're looking for or contact the owner to enable Public access."
I have no idea what is going on here.
22 Replies
The keyword in that error is "This object does not exist or ...", you're just trying to access a non-existent object.
If you're expecting a listing or something like that, there isn't one, you can only directly navigate to objects
Thanks Chaika, the object is the uploaded file right?
(if your bucket was private/not publicily viewable, it would throw a 401 - this bucket cannot be viewed)
I have uploaded a file into the bucket
If you uploaded something yea, you can see all your objects in the dashboard under R2
Yes, I do uploaded one file there. I can see it under the bucket
Make sure you're not appending the bucket name to your path, it's just
https://pub-<uuid>.r2.dev/<filename>
If that's not it, what do you see in your bucket, and what's your r2.dev url?
https://pub-1b348e470bee4d38a8842b496808a871.r2.dev
This is automatically generated by the system
What do you see in your bucket listing in the dashboard (a screenshot would help)?
It may be worth noting as well, by enabling public access, everything in your bucket will be accessible by URL. If there's anything private in there, you'd want some access control in front of it, either with a worker or something else
I have uploaded only 1 file for test.
You'd access it by
https://pub-1b348e470bee4d38a8842b496808a871.r2.dev/somethingblurred%20Release(1).apk
(of course, replacing somethingblurred with the actual filename)Oh, thanks very much. Got it now.
Can I ask for one more question?
Sure
Just one other thing I'd note: the r2.dev, as it says, is meant only for testing and not for production use cases. For production, use a custom domain of your own, which you can attach in the bucket settings
With your own custom domain you can use cache rules/page rules to force cache as well, and any cache hit doesn't cost you a class b/any r2 costs
Yes, this is about the thing I wanna ask.
I have added a custom domain. But it seems the same Error 404
You can't get your file using the file name, in the same way as you can with the pub-r2.dev?
All right. It worked, so it is the same, I have to add the file name after my custom domain, right?
Like: xxx.com/somethingblurred%20Release(1).apk
Correct yea. If you were trying to do a setup where you wanted root (/) to return a specific file, you could use a Transform rule to accomplish that
Where I can find the transform rule?
https://developers.cloudflare.com/rules/transform/url-rewrite/create-dashboard/, under Rules -> Transform Rules in Cloudflare dashboard for your website, magic link: https://dash.cloudflare.com/?to=/:account/:zone/rules/transform-rules/rewrite-url/new
Specifically, you want URL Rewrite, something like this:
Transform rules are modifications to the path that get sent to the origin -- i.e there is no redirect/the user doesn't see their path change
Thanks very much Chaika. Thanks so much for your help.
I will go and check it.