| title | Secrets |
|---|---|
| description | Environment secrets are sensitive configuration settings, such as API keys, passwords, or tokens, that are securely stored and used by your script. |
Environment secrets hold sensitive configuration values, such as API keys, passwords, or tokens. Your script reads them at runtime, so they never have to appear in your source code.
Unlike environment variables, secrets cannot be viewed once they are set. You can only update or delete them, which keeps the value hidden even from people with dashboard access.
To add a secret to your script:
- Log in to the bunny.net dashboard.
- Select Edge Platform, click on Scripting, and select the script.
- Select Env Configuration and Environment Secrets, and fill in the details of the secret you want to create.
- Click Save Secret.
Environment secrets are accessed in the same way as environment variables, using either the Node.js process module or Deno.env.
import * as BunnySDK from "@bunny.net/edgescript-sdk";
import process from "node:process";
BunnySDK.net.http.serve(async (request: Request): Response | Promise<Response> => {
// Load secret named ApiKey
const apiKey = process.env.ApiKey;
// Use the secret in an API request
const response = await fetch("https://api.example.com/data", {
headers: {
"Authorization": `Bearer ${apiKey}`
}
});
return new Response(await response.text());
});You can also use Deno.env.get():
const apiKey = Deno.env.get("ApiKey");
