texan
texan
CDCloudflare Developers
Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
Yeah, technically there is a small overhead, but the worker is executing at the edge close to your users. I think even with this type of setup you're probably better than firebase (which could definitely have higher cold start times unless you pay for reserved instances)
12 replies
CDCloudflare Developers
Created by Paulo S Klaus on 4/4/2025 in #workers-help
Avoid hardcoded IDs in the repository
If you're using CICD you could also do some hacky thing to modify your jsonc/toml prior to invoking Wrangler... but yeah no option that I know of to avoid hardcoding the ID for a D1 binding
7 replies
CDCloudflare Developers
Created by Paulo S Klaus on 4/4/2025 in #workers-help
Avoid hardcoded IDs in the repository
D1 bindings must be declared at build time.. you can't create or switch them dynamically at runtime. What you could do is have a .gitignore and wrangler.secret.jsonc file, and then specify --config when you're building locally
7 replies
CDCloudflare Developers
Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
12 replies
CDCloudflare Developers
Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
Not out of the box, but you could create your own _middleware.js which does the rewrite for you
export const onRequest: MiddlewareHandler = async ({ request, next }) => {
const url = new URL(request.url)
const match = url.pathname.match(/^\/ws\/[^\/]+\/(viewtype[^\/]+)$/)

if (match) {
// Rewrite to /ws/viewtypexxx.html
url.pathname = `/ws/${match[1]}.html`
return fetch(url.toString(), request)
}

return next()
}
export const onRequest: MiddlewareHandler = async ({ request, next }) => {
const url = new URL(request.url)
const match = url.pathname.match(/^\/ws\/[^\/]+\/(viewtype[^\/]+)$/)

if (match) {
// Rewrite to /ws/viewtypexxx.html
url.pathname = `/ws/${match[1]}.html`
return fetch(url.toString(), request)
}

return next()
}
12 replies
CDCloudflare Developers
Created by Deo Kumar on 4/3/2025 in #workers-help
Deploy to Cloudflare button doesn't work
You mentioned the dashboard shows error dialog. Can you share the error details? What's the page you're on when the error occurs? Anything intetesting in the network tab?
14 replies
CDCloudflare Developers
Created by Deo Kumar on 4/3/2025 in #workers-help
Deploy to Cloudflare button doesn't work
I'm able to import a new project from your button (though it fails in Cloudflare dash later for different reasons)
14 replies
CDCloudflare Developers
Created by Deo Kumar on 4/3/2025 in #workers-help
Deploy to Cloudflare button doesn't work
Does it attempt to clone the repository? Do you see a build started for it?
14 replies
CDCloudflare Developers
Created by darkpool on 4/3/2025 in #workers-help
Are event handlers necessary for RPC?
Yup, Workers expects a handler, even if you only want to invoke it via RPC. Workers need a defined way to process incoming requests.
3 replies
CDCloudflare Developers
Created by Mubo on 3/27/2025 in #pages-help
Environment variables dissappeared ??
Do you manage vars in dash or wrangler? How did you push your new code (wrangler?)?
3 replies
CDCloudflare Developers
Created by beelzabub on 3/20/2025 in #workers-help
Multiple assets bindings within a single worker
Hey Vitali, yeah right now there's just only 1 "pool" of assets which are scoped for a worker. There would be no benefit to having multiple asset bindings at the moment.
3 replies
CDCloudflare Developers
Created by Andrew0091 on 3/18/2025 in #workers-help
Whats the best route to take to build PR previews?
You can generate a preview for any version (even if it's not deployed!). I would image your best route would be to do a wrangler version upload so you can access the preview url for those branches.
2 replies