Need help with r2 in pages

I am trying to follow https://developers.cloudflare.com/pages/tutorials/use-r2-as-static-asset-storage-for-pages/ and it doesn't seem to be working. I would expect such an asset to show up here: https://c4f64a53.sqm-website.pages.dev/tutorials/rig/v4/BPS_Rig_v4.zip However I am getting this error in my build log.
2025-08-06T23:34:44.154089Z Cloning repository...
2025-08-06T23:34:47.709651Z From https://github.com/Squared-Media/website
2025-08-06T23:34:47.710498Z * branch 98027eb7fd111a7015cdb445ee3723bc8ef8676e -> FETCH_HEAD
2025-08-06T23:34:47.71066Z
2025-08-06T23:34:47.803916Z HEAD is now at 98027eb Create wrangler.toml
2025-08-06T23:34:47.804633Z
2025-08-06T23:34:47.886021Z
2025-08-06T23:34:47.886499Z Using v2 root directory strategy
2025-08-06T23:34:47.911563Z Success: Finished cloning repository files
2025-08-06T23:34:48.662064Z No build output detected to cache. Skipping.
2025-08-06T23:34:48.662797Z No dependencies detected to cache. Skipping.
2025-08-06T23:34:49.721169Z Checking for configuration in a Wrangler configuration file (BETA)
2025-08-06T23:34:49.721778Z
2025-08-06T23:34:49.723225Z Found wrangler.toml file. Reading build configuration...
2025-08-06T23:34:50.825582Z A wrangler.toml file was found but it does not appear to be valid. Did you mean to use wrangler.toml to configure Pages? If so, then make sure the file is valid and contains the `pages_build_output_dir` property. Skipping file and continuing.
2025-08-06T23:34:50.825998Z No build command specified. Skipping build step.
2025-08-06T23:34:50.826693Z Found Functions directory at /functions. Uploading.
2025-08-06T23:34:50.833382Z ⛅️ wrangler 3.101.0
2025-08-06T23:34:50.833711Z -------------------
2025-08-06T23:34:51.795127Z ✨ Compiled Worker successfully
2025-08-06T23:34:52.872987Z Validating asset output directory
2025-08-06T23:34:55.737482Z Deploying your site to Cloudflare's global network...
2025-08-06T23:34:59.160765Z Uploading... (71/72)
2025-08-06T23:34:59.672236Z Uploading... (72/72)
2025-08-06T23:34:59.672592Z ✨ Success! Uploaded 1 files (71 already uploaded) (0.93 sec)
2025-08-06T23:34:59.673279Z
2025-08-06T23:35:00.070271Z ✨ Upload complete!
2025-08-06T23:35:05.981435Z Success: Assets published!
2025-08-06T23:35:08.175947Z Success: Your site was deployed!
2025-08-06T23:34:44.154089Z Cloning repository...
2025-08-06T23:34:47.709651Z From https://github.com/Squared-Media/website
2025-08-06T23:34:47.710498Z * branch 98027eb7fd111a7015cdb445ee3723bc8ef8676e -> FETCH_HEAD
2025-08-06T23:34:47.71066Z
2025-08-06T23:34:47.803916Z HEAD is now at 98027eb Create wrangler.toml
2025-08-06T23:34:47.804633Z
2025-08-06T23:34:47.886021Z
2025-08-06T23:34:47.886499Z Using v2 root directory strategy
2025-08-06T23:34:47.911563Z Success: Finished cloning repository files
2025-08-06T23:34:48.662064Z No build output detected to cache. Skipping.
2025-08-06T23:34:48.662797Z No dependencies detected to cache. Skipping.
2025-08-06T23:34:49.721169Z Checking for configuration in a Wrangler configuration file (BETA)
2025-08-06T23:34:49.721778Z
2025-08-06T23:34:49.723225Z Found wrangler.toml file. Reading build configuration...
2025-08-06T23:34:50.825582Z A wrangler.toml file was found but it does not appear to be valid. Did you mean to use wrangler.toml to configure Pages? If so, then make sure the file is valid and contains the `pages_build_output_dir` property. Skipping file and continuing.
2025-08-06T23:34:50.825998Z No build command specified. Skipping build step.
2025-08-06T23:34:50.826693Z Found Functions directory at /functions. Uploading.
2025-08-06T23:34:50.833382Z ⛅️ wrangler 3.101.0
2025-08-06T23:34:50.833711Z -------------------
2025-08-06T23:34:51.795127Z ✨ Compiled Worker successfully
2025-08-06T23:34:52.872987Z Validating asset output directory
2025-08-06T23:34:55.737482Z Deploying your site to Cloudflare's global network...
2025-08-06T23:34:59.160765Z Uploading... (71/72)
2025-08-06T23:34:59.672236Z Uploading... (72/72)
2025-08-06T23:34:59.672592Z ✨ Success! Uploaded 1 files (71 already uploaded) (0.93 sec)
2025-08-06T23:34:59.673279Z
2025-08-06T23:35:00.070271Z ✨ Upload complete!
2025-08-06T23:35:05.981435Z Success: Assets published!
2025-08-06T23:35:08.175947Z Success: Your site was deployed!
Cloudflare Docs
Use R2 as static asset storage with Cloudflare Pages
This tutorial will teach you how to use R2 as a static asset storage bucket for your Pages app. This is especially helpful if you're hitting the file limit or the max file size limit on Pages.
No description
No description
No description
No description
41 Replies
Hard@Work
Hard@Work3w ago
Looks like your wrangler.toml is invalid?
Frerduro
FrerduroOP3w ago
Thats what the log says but idk how to fix it tbh
Hard@Work
Hard@Work3w ago
Your wrangler.toml needs more than just what is mentioned there. https://developers.cloudflare.com/pages/functions/wrangler-configuration/
Cloudflare Docs
Configuration
Pages Functions can be configured two ways, either via the Cloudflare dashboard or the Wrangler configuration file, a file used to customize the development and deployment setup for Workers and Pages Functions.
Frerduro
FrerduroOP3w ago
my workers.toml is the 3rd image
Hard@Work
Hard@Work3w ago
Looks like the minimum required is name and pages_build_output_dir
Frerduro
FrerduroOP3w ago
I was just following this
No description
Hard@Work
Hard@Work3w ago
Might need to be more clear, but it means you need to add that to an existing config. It, on its own, isn't enough Though also, we recommend using Workers instead of Pages if possible
Frerduro
FrerduroOP3w ago
tbh thats another thing I would need to learn we are just running a static html site what do I put for pages_build_output_dir
Hard@Work
Hard@Work3w ago
Wherever your files to be uploaded are placed, usually dist or similar
Frerduro
FrerduroOP3w ago
No description
Frerduro
FrerduroOP3w ago
currently its blank on the sites side
Hard@Work
Hard@Work3w ago
Probably just "" then?
Frerduro
FrerduroOP3w ago
ill try
2025-08-06T23:49:00.768476Z Cloning repository...
2025-08-06T23:49:04.29343Z From https://github.com/Squared-Media/website
2025-08-06T23:49:04.293906Z * branch fb107e445a180de1c34ec76995d0a57f11e45345 -> FETCH_HEAD
2025-08-06T23:49:04.294049Z
2025-08-06T23:49:04.388115Z HEAD is now at fb107e4 Update wrangler.toml
2025-08-06T23:49:04.388646Z
2025-08-06T23:49:04.470614Z
2025-08-06T23:49:04.471231Z Using v2 root directory strategy
2025-08-06T23:49:04.493091Z Success: Finished cloning repository files
2025-08-06T23:49:20.235676Z Success: Assets published!
2025-08-06T23:49:22.467732Z Success: Your site was deployed!
2025-08-06T23:49:00.768476Z Cloning repository...
2025-08-06T23:49:04.29343Z From https://github.com/Squared-Media/website
2025-08-06T23:49:04.293906Z * branch fb107e445a180de1c34ec76995d0a57f11e45345 -> FETCH_HEAD
2025-08-06T23:49:04.294049Z
2025-08-06T23:49:04.388115Z HEAD is now at fb107e4 Update wrangler.toml
2025-08-06T23:49:04.388646Z
2025-08-06T23:49:04.470614Z
2025-08-06T23:49:04.471231Z Using v2 root directory strategy
2025-08-06T23:49:04.493091Z Success: Finished cloning repository files
2025-08-06T23:49:20.235676Z Success: Assets published!
2025-08-06T23:49:22.467732Z Success: Your site was deployed!
Frerduro
FrerduroOP3w ago
No description
Hard@Work
Hard@Work3w ago
Looks like it completely skipped wrangler... weird Not sure why that would happen tbh
Frerduro
FrerduroOP3w ago
No description
Hard@Work
Hard@Work3w ago
Long guess, but maybe try /?
Frerduro
FrerduroOP3w ago
2025-08-06T23:51:50.249539Z Cloning repository...
2025-08-06T23:51:53.76439Z From https://github.com/Squared-Media/website
2025-08-06T23:51:53.764904Z * branch b2de84dcf9b93b352d09fb34dce279f701db4c03 -> FETCH_HEAD
2025-08-06T23:51:53.765032Z
2025-08-06T23:51:53.8604Z HEAD is now at b2de84d Update wrangler.toml
2025-08-06T23:51:53.861392Z
2025-08-06T23:51:53.941929Z
2025-08-06T23:51:53.942477Z Using v2 root directory strategy
2025-08-06T23:51:53.965165Z Success: Finished cloning repository files
2025-08-06T23:51:54.607391Z No build output detected to cache. Skipping.
2025-08-06T23:51:54.608105Z No dependencies detected to cache. Skipping.
2025-08-06T23:51:55.660091Z Checking for configuration in a Wrangler configuration file (BETA)
2025-08-06T23:51:55.660835Z
2025-08-06T23:51:55.662072Z Found wrangler.toml file. Reading build configuration...
2025-08-06T23:51:55.669242Z pages_build_output_dir: ../../..
2025-08-06T23:51:55.669431Z Build environment variables: (none found)
2025-08-06T23:51:56.773008Z Successfully read wrangler.toml file.
2025-08-06T23:51:56.773791Z No build command specified. Skipping build step.
2025-08-06T23:51:57.876358Z Failed: an internal error occurred. If this continues, contact support: https://cfl.re/3WgEyrH
2025-08-06T23:51:50.249539Z Cloning repository...
2025-08-06T23:51:53.76439Z From https://github.com/Squared-Media/website
2025-08-06T23:51:53.764904Z * branch b2de84dcf9b93b352d09fb34dce279f701db4c03 -> FETCH_HEAD
2025-08-06T23:51:53.765032Z
2025-08-06T23:51:53.8604Z HEAD is now at b2de84d Update wrangler.toml
2025-08-06T23:51:53.861392Z
2025-08-06T23:51:53.941929Z
2025-08-06T23:51:53.942477Z Using v2 root directory strategy
2025-08-06T23:51:53.965165Z Success: Finished cloning repository files
2025-08-06T23:51:54.607391Z No build output detected to cache. Skipping.
2025-08-06T23:51:54.608105Z No dependencies detected to cache. Skipping.
2025-08-06T23:51:55.660091Z Checking for configuration in a Wrangler configuration file (BETA)
2025-08-06T23:51:55.660835Z
2025-08-06T23:51:55.662072Z Found wrangler.toml file. Reading build configuration...
2025-08-06T23:51:55.669242Z pages_build_output_dir: ../../..
2025-08-06T23:51:55.669431Z Build environment variables: (none found)
2025-08-06T23:51:56.773008Z Successfully read wrangler.toml file.
2025-08-06T23:51:56.773791Z No build command specified. Skipping build step.
2025-08-06T23:51:57.876358Z Failed: an internal error occurred. If this continues, contact support: https://cfl.re/3WgEyrH
Hard@Work
Hard@Work3w ago
Hm, yeah, not sure
Frerduro
FrerduroOP3w ago
2025-08-06T23:53:22.70489Z Cloning repository...
2025-08-06T23:53:26.293989Z From https://github.com/Squared-Media/website
2025-08-06T23:53:26.294703Z * branch b75b15e93bb2ccb1537bd384b505ac574fb18259 -> FETCH_HEAD
2025-08-06T23:53:26.295012Z
2025-08-06T23:53:26.386104Z HEAD is now at b75b15e Update wrangler.toml
2025-08-06T23:53:26.386634Z
2025-08-06T23:53:26.469194Z
2025-08-06T23:53:26.469719Z Using v2 root directory strategy
2025-08-06T23:53:26.491612Z Success: Finished cloning repository files
2025-08-06T23:53:27.512793Z No build output detected to cache. Skipping.
2025-08-06T23:53:27.513532Z No dependencies detected to cache. Skipping.
2025-08-06T23:53:28.535818Z Checking for configuration in a Wrangler configuration file (BETA)
2025-08-06T23:53:28.536561Z
2025-08-06T23:53:28.537841Z Found wrangler.toml file. Reading build configuration...
2025-08-06T23:53:28.544377Z pages_build_output_dir: dist
2025-08-06T23:53:28.544576Z Build environment variables: (none found)
2025-08-06T23:53:29.661287Z Successfully read wrangler.toml file.
2025-08-06T23:53:29.661862Z No build command specified. Skipping build step.
2025-08-06T23:53:29.662415Z Found Functions directory at /functions. Uploading.
2025-08-06T23:53:29.668635Z ⛅️ wrangler 3.101.0
2025-08-06T23:53:29.668913Z -------------------
2025-08-06T23:53:30.595375Z ✨ Compiled Worker successfully
2025-08-06T23:53:31.679901Z Validating asset output directory
2025-08-06T23:53:31.680435Z Error: Output directory "dist" not found.
2025-08-06T23:53:32.755538Z Failed: build output directory not found
2025-08-06T23:53:22.70489Z Cloning repository...
2025-08-06T23:53:26.293989Z From https://github.com/Squared-Media/website
2025-08-06T23:53:26.294703Z * branch b75b15e93bb2ccb1537bd384b505ac574fb18259 -> FETCH_HEAD
2025-08-06T23:53:26.295012Z
2025-08-06T23:53:26.386104Z HEAD is now at b75b15e Update wrangler.toml
2025-08-06T23:53:26.386634Z
2025-08-06T23:53:26.469194Z
2025-08-06T23:53:26.469719Z Using v2 root directory strategy
2025-08-06T23:53:26.491612Z Success: Finished cloning repository files
2025-08-06T23:53:27.512793Z No build output detected to cache. Skipping.
2025-08-06T23:53:27.513532Z No dependencies detected to cache. Skipping.
2025-08-06T23:53:28.535818Z Checking for configuration in a Wrangler configuration file (BETA)
2025-08-06T23:53:28.536561Z
2025-08-06T23:53:28.537841Z Found wrangler.toml file. Reading build configuration...
2025-08-06T23:53:28.544377Z pages_build_output_dir: dist
2025-08-06T23:53:28.544576Z Build environment variables: (none found)
2025-08-06T23:53:29.661287Z Successfully read wrangler.toml file.
2025-08-06T23:53:29.661862Z No build command specified. Skipping build step.
2025-08-06T23:53:29.662415Z Found Functions directory at /functions. Uploading.
2025-08-06T23:53:29.668635Z ⛅️ wrangler 3.101.0
2025-08-06T23:53:29.668913Z -------------------
2025-08-06T23:53:30.595375Z ✨ Compiled Worker successfully
2025-08-06T23:53:31.679901Z Validating asset output directory
2025-08-06T23:53:31.680435Z Error: Output directory "dist" not found.
2025-08-06T23:53:32.755538Z Failed: build output directory not found
didn't like "./dist" either
Hard@Work
Hard@Work3w ago
What if you move all of the files you want to upload(minus your wrangler.toml) to dist first?
Frerduro
FrerduroOP3w ago
or public? going over this and im kinda guessing they are using public as their build output dir?
No description
Hard@Work
Hard@Work3w ago
Yeah, that's correct
Frerduro
FrerduroOP3w ago
alright imma give it a try
Hard@Work
Hard@Work3w ago
Just need a directory, doesn't really matter what name it is
Frerduro
FrerduroOP3w ago
2025-08-07T00:04:05.093535Z Cloning repository...
2025-08-07T00:04:08.612567Z From https://github.com/Squared-Media/website
2025-08-07T00:04:08.613054Z * branch 16e2da554c3b5780651dc6474cf8508aa9a25350 -> FETCH_HEAD
2025-08-07T00:04:08.61325Z
2025-08-07T00:04:08.706943Z HEAD is now at 16e2da5 Update wrangler.toml
2025-08-07T00:04:08.707442Z
2025-08-07T00:04:08.786642Z
2025-08-07T00:04:08.787098Z Using v2 root directory strategy
2025-08-07T00:04:08.808266Z Success: Finished cloning repository files
2025-08-07T00:04:09.504426Z No build output detected to cache. Skipping.
2025-08-07T00:04:09.505123Z No dependencies detected to cache. Skipping.
2025-08-07T00:04:10.507348Z Checking for configuration in a Wrangler configuration file (BETA)
2025-08-07T00:04:10.508235Z
2025-08-07T00:04:10.509554Z Found wrangler.toml file. Reading build configuration...
2025-08-07T00:04:10.516059Z pages_build_output_dir: public
2025-08-07T00:04:10.516251Z Build environment variables: (none found)
2025-08-07T00:04:11.63192Z Successfully read wrangler.toml file.
2025-08-07T00:04:11.632839Z No build command specified. Skipping build step.
2025-08-07T00:04:11.63365Z Found Functions directory at /functions. Uploading.
2025-08-07T00:04:11.640204Z ⛅️ wrangler 3.101.0
2025-08-07T00:04:11.640349Z -------------------
2025-08-07T00:04:12.56831Z ✨ Compiled Worker successfully
2025-08-07T00:04:13.676487Z Validating asset output directory
2025-08-07T00:04:16.524762Z Deploying your site to Cloudflare's global network...
2025-08-07T00:04:20.92125Z Uploading... (71/71)
2025-08-07T00:04:20.922092Z ✨ Success! Uploaded 0 files (71 already uploaded) (0.24 sec)
2025-08-07T00:04:20.922303Z
2025-08-07T00:04:21.473602Z ✨ Upload complete!
2025-08-07T00:04:25.117517Z Success: Assets published!
2025-08-07T00:04:27.226627Z Success: Your site was deployed!
2025-08-07T00:04:05.093535Z Cloning repository...
2025-08-07T00:04:08.612567Z From https://github.com/Squared-Media/website
2025-08-07T00:04:08.613054Z * branch 16e2da554c3b5780651dc6474cf8508aa9a25350 -> FETCH_HEAD
2025-08-07T00:04:08.61325Z
2025-08-07T00:04:08.706943Z HEAD is now at 16e2da5 Update wrangler.toml
2025-08-07T00:04:08.707442Z
2025-08-07T00:04:08.786642Z
2025-08-07T00:04:08.787098Z Using v2 root directory strategy
2025-08-07T00:04:08.808266Z Success: Finished cloning repository files
2025-08-07T00:04:09.504426Z No build output detected to cache. Skipping.
2025-08-07T00:04:09.505123Z No dependencies detected to cache. Skipping.
2025-08-07T00:04:10.507348Z Checking for configuration in a Wrangler configuration file (BETA)
2025-08-07T00:04:10.508235Z
2025-08-07T00:04:10.509554Z Found wrangler.toml file. Reading build configuration...
2025-08-07T00:04:10.516059Z pages_build_output_dir: public
2025-08-07T00:04:10.516251Z Build environment variables: (none found)
2025-08-07T00:04:11.63192Z Successfully read wrangler.toml file.
2025-08-07T00:04:11.632839Z No build command specified. Skipping build step.
2025-08-07T00:04:11.63365Z Found Functions directory at /functions. Uploading.
2025-08-07T00:04:11.640204Z ⛅️ wrangler 3.101.0
2025-08-07T00:04:11.640349Z -------------------
2025-08-07T00:04:12.56831Z ✨ Compiled Worker successfully
2025-08-07T00:04:13.676487Z Validating asset output directory
2025-08-07T00:04:16.524762Z Deploying your site to Cloudflare's global network...
2025-08-07T00:04:20.92125Z Uploading... (71/71)
2025-08-07T00:04:20.922092Z ✨ Success! Uploaded 0 files (71 already uploaded) (0.24 sec)
2025-08-07T00:04:20.922303Z
2025-08-07T00:04:21.473602Z ✨ Upload complete!
2025-08-07T00:04:25.117517Z Success: Assets published!
2025-08-07T00:04:27.226627Z Success: Your site was deployed!
still getting a 404 though
Frerduro
FrerduroOP3w ago
No description
No description
Frerduro
FrerduroOP3w ago
oh im dumb it is working I just needed to add a 2nd /tutorials/ https://fcac5a9e.sqm-website.pages.dev/tutorials/tutorials/rig/v4/BPS_Rig_v4.zip
Frerduro
FrerduroOP3w ago
Question is, Is there a way to change the root dir it starts inside our R2 storage?
No description
Hello, I’m Allie!
Remove the replace?
Frerduro
FrerduroOP3w ago
remove this part or do you mean remove the whole line?
No description
Hello, I’m Allie!
Yeah, just that part. Then any request to /tutorials/* would be routed to tutorials/* in your bucket, if that was what you were going for? Or if you want a different subdirectory, you can change the folder the function is in
Frerduro
FrerduroOP3w ago
That doesn't seem to work.
Hello, I’m Allie!
To confirm I have it right, which directory do you want to serve from in your bucket, and which path prefix do you want to use on Pages?
Frerduro
FrerduroOP3w ago
In R2 we have a tutorials dir which goes into tutorials/rig/*
No description
Frerduro
FrerduroOP3w ago
I was just wanting it to follow the dir structure of the bucket
Frerduro
FrerduroOP3w ago
Squared Media
Official home of Squared Media and all its projects.
Squared Media
Official home of Squared Media and all its projects.
No description
Hello, I’m Allie!
Ok, might be me being dumb, but could you do .pathname.slice(1)? That should remove the first slash from the path
Frerduro
FrerduroOP3w ago
Where would that go?
Hard@Work
Hard@Work3w ago
Like this:
const path = new URL(ctx.request.url).pathname.slice(1);
const path = new URL(ctx.request.url).pathname.slice(1);
Frerduro
FrerduroOP3w ago
That solved my issue thank you 🙂

Did you find this page helpful?