#R2 script not functioning when It tries deploying on CF pages, but works locally.

13 messages · Page 1 of 1 (latest)

verbal ferry
#

I have a script to sync a directory to an R2 bucket, and running it locally with all my env stuff in .env works fine. Uploading .env to the environment variables for my deployment build settings, and trying to deploy, it fails and gives me Error: AccessDenied: Access Denied, when this gets executed:

const response = await r2Client.send(
    new ListObjectsV2Command({
        Bucket: BUCKET_NAME,
        ContinuationToken: continuationToken,
    })
);
#

r2Client is initiated fine, and running locally executes fine

balmy sinew
verbal ferry
verbal ferry
#

anything else?

balmy sinew
# verbal ferry anything else?

there's not a whole lot to the setup, add logging/debugging in your script to ensure env vars are set properly when running in the build container. Make sure you have no IP Restrictions on the R2 token either

verbal ferry
#

Oh my God

#

You're right

#

IP

#

Thanks a ton

#

Is there any IP I can assign for the worker or anything?

balmy sinew