and I guess Prom in a DO means saving the state of a counter in the DO 😅

and I guess Prom in a DO means saving the state of a counter in the DO 😅
12 Replies
0x146231489231923
how you all do logging for production debugging in worker? the free plan doesnt do much
ac
ac3mo ago
Is there an issue with worker CI/CD builds? This happened yesterday and it's happening to me again, but all of my workers build statuses are just "Queued" even though there are no builds running. ^ I believe I've found a bug with Workers CI/CD, what's the best place to report that? (I was able to reproduce the issue, and it seems related to my setup and how Workers CI is triggered)
Constantin
Constantin3mo ago
can anyone please advice related to custom domains. I'm trying to create a sass king of app. 1. I managed to create tenant wildcard subdomains by using pages and a custom proxy worker. eg. https://ionica.app.greatoutdoors.live/ 2. I added the custom domain on my side 3. tenant added CNAME servicii.cmnstmntm.com -> ionica.app.greatoutdoors.live however, the request to https://servicii.cmnstmntmn.com/ is timing out. this is the traceroute
No description
Constantin
Constantin3mo ago
is this even possible with my plan? i assumed it is since i could add the custom domain
Chaika
Chaika3mo ago
Do you have a wildcard catch-all route? https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/start/advanced-settings/worker-as-origin/. Unproxied CF For SaaS hostnames come through as the actual hostname, ex it's looking for a worker route matching servicii.cmnstmntmn.com and Worker Custom Domains just won't work Be careful not to break your existing subdomains/domain with that. I usually recommend people get a separate domain just for customer custom domains to avoid issues with that and the fact that all custom hostnames inherit your zone's configuration (waf rules, config rules, network settings, etc), so better to eliminate the possibility of non-intentionally changing settings for them/more flexibility with your custom domains
Cloudflare Docs
Workers as your fallback origin | Cloudflare for Platforms docs
Learn how to use a Worker as the fallback origin for your SaaS zone.
Constantin
Constantin3mo ago
yes, the worker has a pattern like this
No description
Constantin
Constantin3mo ago
so i need a worker that handles the origin specifically thanks @Chaika i'll give it a try
Chaika
Chaika3mo ago
no that's not a wildcard catch-all (well, not as wide as CF For SaaS needs) */* is a wildcard catch-all sounds like you might have figured out the rest but yea, you need an actual full wildcard
Alexander Hupfer
Hi, I have a worker that somehow can't connect to a D1 datbase using Prisma, but it works locally. What would be you recommendation on debugging this? I just see "Internal Server Error"
Constantin
Constantin3mo ago
@Chaika you're a genius! thank you
No description
timousy
timousy3mo ago
Hello everyone I have a static maintenance mode html page that is stored in Worker KV, which is only displayed to users whose ip address is not in the whitelist. I'm trying to replace some text in my html file stored in Worker KV with Worker Here is a part from my html file
<section> <h2>Your IP Address: <span id="user-ip">Loading...</span></h2> </section>
I want to replace the word “Loading...” with the ip address of my user Here's a script example from my Worker where I'm trying to replace
async function handleFetch(event) { let ip = event.request.headers.get('cf-connecting-ip'); let customersIPsRangesJson = await $(cloudflare_kv_name).get('$(employee_ip_range_key)', 'json') || []; const isIPInRange = customersIPsRangesJson.some(range => { return range && range.includes('-') && checkIPInRange(ip, range); }); if (isIPInRange) { return fetch(event.request); } else { return handleEvent(event, ip); } } class TextRewriter { constructor(newText) { this.newText = newText; } element(element) { const newContent = <span id="user-ip">${this.newText}</span>; element.replace(newContent, { html: true }); } } async function handleEvent(event, ip) { try { if (DEBUG) { // customize caching options.cacheControl = { bypassCache: true, }; } const page = await getAssetFromKV(event, options); const response = new Response(page.body, page); // allow headers to be altered response.headers.set("X-XSS-Protection", "1; mode=block"); response.headers.set("X-Content-Type-Options", "nosniff"); response.headers.set("X-Frame-Options", "DENY"); response.headers.set("Referrer-Policy", "unsafe-url"); response.headers.set("Feature-Policy", "none"); // Using HTMLRewriter to insert the IP address const rewriter = new HTMLRewriter() .on('span#user-ip', new TextRewriter(ip)); return rewriter.transform(response); }
As you can see, I'm trying to get the ip from the > async function handleFetch(event) using the command let ip = event.request.headers.get('cf-connecting-ip'); Unfortunately, I cannot replace the word “Loading...” with the ip address, maybe you can help me with this, I will be very grateful PS. I apologize in advance for any discrepancies in my explanations, I'm actually still quite new to Cloudflare Workers, and JS in general)
Want results from more Discord servers?
Add your server