Injecting Environment Variables into a Worker

I am currently developing a slackbot using Cloudflare workers with webpack and serverless. What is the best practice for injecting env variables into the worker?

cheers

1 Like

You can use KV (key/value) for that.

What’s the workflow. is it

Inject env variables into KV store and then deploy the worker?

Is it possible to use serverless for that or do we need to do it out of process.

You keep any setting you need in KV and deploy your worker. Your worker can access KV. It is recommended to use KV for reading although your worker can write, writes take a while to get synced across network and you cannot count on that for atomic operations.

thanks for the timely response

1 Like

So basically no env vars?

How do people normally cope with different environments? I’ve got 2 testing environments and live and there’s no clear way to cope with this. Ultimately want to push the worker code through a CI/CD process.

A post was split to a new topic: How to inject environment variables into webpack?