GATES
GATES
CDCloudflare Developers
Created by GATES on 7/31/2024 in #workers-help
Is there an alternative to --branch on worker deploys like pages?
A feature we use extensivley on pages is the --branch flag so we get dynamic preview environments. On workers though, we dont have the same flexibility. We have --env but that seems to be required to be --preview which doesnt work as we need individual environment domains to test on. Is this something anyone else has got around another way?
2 replies
CDCloudflare Developers
Created by GATES on 7/23/2024 in #pages-help
Build domains vs branch domain
I just had a quick question/confirmation I hope you'd be able to be able to help with. When deploying our pages applications to a preview branch, we receive a URL like abc123.myapp.pages.dev, where the prefix is a sort of has provided by cloudflare. What I've noticed is that these prefix's seem to be interchangeable with the branch name that was passed in. for example if i have a branch of "mybranch" everytime I deploy to this branch, i can access that preview via "mybranch.myapp.pages.dev". Am I correct in this and is it trustworthy to use that or for some reason and should not use these and only use the build hash that has been given to me via the build (abc123)? as im not sure this is documented much so wasnt sure if you'd recommend using the hash instead of the branch.
3 replies
CDCloudflare Developers
Created by GATES on 5/21/2024 in #pages-help
Pages Caching
Does cloudflare pages respect Cache-Control headers? If so, how can I validate that? When i use Cache API directly i get a Cache Status HIT response header, however id like to avoid this if possible and would ideally use Cache Rules instead. Ive set it to respect the Cache-Control header and they are set correctly, however cannot see the Cache Status HIT header anymore. Is there another way to validate this working? or does it require the use of the Cache API directly?
16 replies
CDCloudflare Developers
Created by GATES on 4/11/2024 in #pages-help
Service binding with pages not working
Ive got a regular worker that im trying to bind to a pages worker so it can forward requests on to it using env.ui_search_trip.fetch(newRequest) ... However im unsure whether CF support binding pages to workers as when i run my deployment it fails attempting to bind
workers.api.error.service_binding_error: could not resolve binding "ui_search_trip": script
"ui-search-trip" not found [code: 10143
workers.api.error.service_binding_error: could not resolve binding "ui_search_trip": script
"ui-search-trip" not found [code: 10143
and when i add environment = production i get a similar error. Should this work? I also cant see the pages in the list of services to bind when im in the dashboard of this parent worker so not sure if it is supported. Heres my wrangler.toml
account_id = "x"
main = "src/index.ts"
compatibility_date = "2024-04-03"
compatibility_flags = ["nodejs_compat"]
[[services]]
binding = "ui_search_trip"
service = "ui-search-trip"

[env.production]
compatibility_date = "2024-04-03"

[[env.production.services]]
binding = "ui_search_trip"
service = "ui-search-trip"
account_id = "x"
main = "src/index.ts"
compatibility_date = "2024-04-03"
compatibility_flags = ["nodejs_compat"]
[[services]]
binding = "ui_search_trip"
service = "ui-search-trip"

[env.production]
compatibility_date = "2024-04-03"

[[env.production.services]]
binding = "ui_search_trip"
service = "ui-search-trip"
1 replies
CDCloudflare Developers
Created by GATES on 4/9/2024 in #pages-help
Preview builds "No deploy available"
When building on our preview branches, the command responds saying it is successful. but when looking at the dashboard it wasnt and says "No deployment available" but doesnt give me a reason. Is there a build output i can look out to figure out why? Production builds dont fail with the same message
9 replies
CDCloudflare Developers
Created by GATES on 4/8/2024 in #pages-help
KV & Pages not binding
I had this working previously, but unsure what has changed... I have a remix pages application where in my loader im using a KV store that i had created through the dashboard. Im running await context.env.KV_SITE_CONFIGS.get('ABC123', { type: 'json' }) and my remix app is running fine locally (I have created the .wrangler state files so this works fine locally). But when pushing to either preview or production environments with my command wrangler pages deploy ./public --branch master --commit-hash $CI_COMMIT_HASH --project-name ui-example Ive updated my wrangler so i use the new wrangler.toml which is below. I know its this call to KV that is the issue as removing it allows my application to load. It doesnt give me a good error response though so cannot identify the issue myself and assume its to do with binding issues. Ive already checked my binding IDs are correct and the data in the dashboard is also populated & the pages app is also binded through the dashboard. also running the kv command directly also works fine: wrangler kv:key get ABC123 --binding=KV_SITE_CONFIGS Id really appreciate some ideas please.
name = "ui-example"
compatibility_date = "2024-02-19"

[[kv_namespaces]]
id = "x"
binding = "KV_SITE_CONFIGS"

[[kv_namespaces]]
id = "x"
binding = "KV_THEME_CONFIGS"

[env.production]
compatibility_date = "2024-02-19"

[[env.production.kv_namespaces]]
id = "x"
binding = "KV_SITE_CONFIGS"

[[env.production.kv_namespaces]]
id = "x"
binding = "KV_THEME_CONFIGS"
name = "ui-example"
compatibility_date = "2024-02-19"

[[kv_namespaces]]
id = "x"
binding = "KV_SITE_CONFIGS"

[[kv_namespaces]]
id = "x"
binding = "KV_THEME_CONFIGS"

[env.production]
compatibility_date = "2024-02-19"

[[env.production.kv_namespaces]]
id = "x"
binding = "KV_SITE_CONFIGS"

[[env.production.kv_namespaces]]
id = "x"
binding = "KV_THEME_CONFIGS"
3 replies
CDCloudflare Developers
Created by GATES on 3/21/2024 in #pages-help
Worker routes for pages
Is anyone aware of a way to setup worker routes for pages? Id like to have a single domain pointing to multiple pages applications based on path. I see worker routes allow you to set the kind of thing id need, like go to X-application based on route being /Y/*... but only traditional workers display in the dropdown, and not my pages applications. as pages are workers under the hood, is there a way to do this?
4 replies
CDCloudflare Developers
Created by GATES on 3/12/2024 in #pages-help
Production branch setup
No description
3 replies