Getting 401 when trying to access bucket objects

Hi all,

I have an R2 bucket with endpoint with a few files on it.
I want to access one of the files so I gathered it should be accessible at
To allow that, I published a worker that allows the access based on a cookie.
When I go on the dashboard on the worker’s page, I can see that the bucket is listed in Settings > R2 Bucket Bindings so I think it is correctly set up to be triggered when a request wants to read a file on the bucket.

When I issue request to get the file, I receive 401 responses though my code does not return 401 errors. And the dashboard shows requests incoming on the charts that correspond to my tests.

Does someone know where those 401 come from?

Could you post a snippet of your Workers code?

Also, which URL are you hitting? I assume your one?

Also, which URL are you hitting? I assume your one?

Well I was hitting the R2 one, but I guess this endpoint is only for AWS SDK.
With the worker’s url in, it works just fine.

Thank you for your time and sorry for the misunderstanding.

Yep - that’s the S3-compatible API endpoint.

Glad it’s sorted.