Is there a PUT Secret API call for cloudflare for Pages?

Hi guys - as the title points out - i've checked out api.cloudflare etc but no dice. I need to store env variables provided by the user.
13 Replies
Chaika
Chaika•6mo ago
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API
Stigin
StiginOP•6mo ago
Perfect thanks @Chaika - couldn't see this for looking! Does this require a redeployment for the secret to become active?
Chaika
Chaika•6mo ago
yup
Stigin
StiginOP•6mo ago
bugger any other options we have currently? I need to store private keys on the fly.
Chaika
Chaika•6mo ago
depends what you need. There's KV or R2 but both have their own latency costs and such Workers for example have the same quick with environment variables except it just does the redeployment automagically for you
Stigin
StiginOP•6mo ago
KV secure enough to put a private key? I guess I could encrypt the private key with a key in the environment variables 🤔
Chaika
Chaika•6mo ago
https://community.cloudflare.com/t/credentials/77012/7?u=chaika I mean Secrets are encrypted at rest and so is KV
Chaika
Chaika•6mo ago
Cloudflare Docs
Data security · Cloudflare Workers KV
This page details the data security properties of KV, including:
Stigin
StiginOP•6mo ago
So that looks fine just would need to watch out for the Access to KV via cloudflare dashboard as the value is not hidden Thanks Chaika I had one other question if you don't mind as well. Cron from sveltekit? Is the best approach here a durable worker with an alarm? I'm using built in API routes into sveltekit. Or is cron exposed to sveltkit via platform env?
Chaika
Chaika•6mo ago
Pages doesn't support CRON, or defining Durable Objects (although you can define them from a worker and then use them from a pages project)
Stigin
StiginOP•6mo ago
Can't you use on sveltekit / pages - just going on whats in the docs for sveltekit - https://kit.svelte.dev/docs/adapter-cloudflare
"export async function POST({ request, platform }) {
const x = platform.env.YOUR_DURABLE_OBJECT_NAMESPACE.idFromName('x');
}"
"export async function POST({ request, platform }) {
const x = platform.env.YOUR_DURABLE_OBJECT_NAMESPACE.idFromName('x');
}"
SvelteKit docs
Cloudflare Pages • SvelteKit documentation
Chaika
Chaika•6mo ago
you can use them when they are defined/created in a seperate worker and then bound to
Stigin
StiginOP•6mo ago
Yep fine. thanks.
Want results from more Discord servers?
Add your server