Skip to content
GigadriveDocs

Injected variables

Every GIGADRIVE_ variable the platform sets inside a deployed Function, and when each one is present.

Gigadrive Network sets these variables inside every Function it starts, on top of the environment variables you configured yourself. They are the whole of the zero-config surface: the SDK reads four of them, and your code can read any of them.

VariableValuePresent
GIGADRIVE_CLIENT_IDClient id of the Function's credential, a UUIDAlways
GIGADRIVE_CLIENT_SECRETClient secret, a gdnet_secret_ string, marked sensitiveAlways
GIGADRIVE_APPLICATION_IDUUID of the application this deployment belongs toAlways
GIGADRIVE_DEPLOYMENT_IDUUID of the deployment serving this FunctionAlways
GIGADRIVE_URLhttps:// plus the deployment's hostnameAlways, and it replaces any GIGADRIVE_URL you set yourself
GIGADRIVE_API_BASE_URLBase URL of the Gigadrive Network APIIn production
GIGADRIVE_API_URLThe same value as GIGADRIVE_API_BASE_URLIn production, always alongside GIGADRIVE_API_BASE_URL

What the SDK reads

GIGADRIVE_CLIENT_ID and GIGADRIVE_CLIENT_SECRET become the client credentials. GIGADRIVE_APPLICATION_ID becomes the default application context, which is why client.storage calls do not need an application argument inside a Function. GIGADRIVE_API_BASE_URL sets the API host.

GIGADRIVE_URL and GIGADRIVE_DEPLOYMENT_ID exist for your code. The SDK never reads them.

// Absolute URL of this deployment, for a callback a third party has to reach.
// The variable is absent on your own machine, hence the local fallback.
const baseUrl = process.env.GIGADRIVE_URL ?? 'http://localhost:3000';
const returnUrl = new URL('/checkout/complete', baseUrl).toString();

Variables you can set yourself

The SDK also reads these when they are present, and none of them is injected. Set them on the application the way you set any other value, as described in Environment variables, when you want a Function to authenticate as something other than itself.

VariableEffect
GIGADRIVE_BEARER_TOKENUses this token as it is and never refreshes it
GIGADRIVE_REFRESH_TOKENRefresh-token flow against the identity provider, paired with GIGADRIVE_CLIENT_ID
GIGADRIVE_IDP_ISSUER_URLOverrides the identity provider issuer, which defaults to https://idp.gigadrive.de
GIGADRIVE_API_BASE_URLOverrides the API host, injected in production but yours to change

Resolution order matters. Options passed to new GigadriveClient({ ... }) beat the environment, and inside the environment a bearer token beats client credentials. Setting GIGADRIVE_BEARER_TOKEN on an application therefore takes its Functions off their own identity, which is rarely what you want.

None of the injected variables exist on your own machine. To get a working pair locally, run gigadrive env pull --with-credentials, described in Using the SDK.