Skip to content

Environment Variables

Read environment variables exposed to the sandbox via the run config.

src/index.ts
import type { ExportedHandler } from "kyushu-types";
export default {
async fetch() {
const apiKey = process.env.API_KEY ?? "not set";
return {
status: 200,
headers: { "content-type": "application/json" },
body: JSON.stringify({ API_KEY: apiKey }),
};
},
} satisfies ExportedHandler;

By default, the sandbox has no access to the host environment. Explicitly expose variables to make them available to your worker.

kyushu.run.toml
[[env]]
key = "API_KEY"
value = "secret"

Try it

Build and run the worker with its config.

Terminal window
kyu build && kyu run kyushu.run.toml

Then send a request to test it.

Terminal window
curl http://localhost:5987