Open morenol opened 3 years ago
We have to check how cloudflare workers work, because I am not sure if we can use environment variables to define the configurations if that is not possible probably we need to look for something different. Does it exist compile time configurations?
I mean in order to define which paths are cached or which is the site that is going to be cached.
Thanks for kick in @morenol!
In relation to environment variables, on Cloudflare Workers you can specify variables via the wrangler.toml file. Refer to the documentation for more details.
I'm not 100% sure if this environment variables are available in the WASM context as well, but I'm pretty sure we can access them straight from this file:
https://github.com/rust-lang-ve/website-worker/blob/main/worker/worker.js
In order to consume Cloudflare's Key/Value storage, I think we can give a try on cloudflare-rs
crate (Which is a Work In Progress, at the moment of this writing).
Part of the main goal is to avoid hitting request limits, by providing this functionality:
maybe we can use a header to disable the cache or add a configuration to cache only certain kind of requests (maybe using regex or something more simple than that)
We would introduce a vulnerability for our logic, I would be agnostic about this and rely on Cache directly for this instead of relying on the consumer for this.
We would introduce a vulnerability for our logic, I would be agnostic about this and rely on Cache directly for this instead of relying on the consumer for this.
You are right, someone with bad intentions could hit our requests limits :(.
But in any case we need to find a way to purge the data in the KV workers. Edit: That can be done with the wrangler CLI: https://developers.cloudflare.com/workers/cli-wrangler/commands#kvkey
In relation to environment variables, on Cloudflare Workers you can specify variables via the wrangler.toml file. Refer to the documentation for more details.
That sounds fine, I already saw that you already added in scripts/make-wrangler.sh all the things needed to create that file with environment variables, so that's nice!
I am opening this issue to discuss about the desing of this project.
The main goal is to create a cloudflare worker that can be used as "proxy" for other sites. It should cache the page using the native KV of Cloudflare, maybe we can use a header to disable the cache or add a configuration to cache only certain kind of requests (maybe using regex or something more simple than that).