Function to get the value for the provided environment variable name.
For a list of available environment variables, see the Fastly Developer Hub for C@E Environment Variables
Note: The environment variables can only be retrieved when processing requests, not during build-time initialization.
In this example we log to stdout the environment variables FASTLY_HOSTNAME and FASTLY_TRACE_ID.
FASTLY_HOSTNAME
FASTLY_TRACE_ID
function app(event) { console.log("FASTLY_HOSTNAME:", env("FASTLY_HOSTNAME")); console.log("FASTLY_TRACE_ID:", env("FASTLY_TRACE_ID"));
return new Response("", { status: 200 }); }
addEventListener("fetch", event => event.respondWith(app(event)));
```
The name of the environment variable
Generated using TypeDoc
Function to get the value for the provided environment variable name.
For a list of available environment variables, see the Fastly Developer Hub for C@E Environment Variables
Note: The environment variables can only be retrieved when processing requests, not during build-time initialization.
Example
In this example we log to stdout the environment variables
FASTLY_HOSTNAME
andFASTLY_TRACE_ID
.