allowDynamicBackends
The allowDynamicBackends()
function is used to control whether or not Dynamic Backends should be allowed within this Compute@Edge Service.
By default, Dynamic Backends are disabled within a JavaScript application as it can be a potential avenue for third-party JavaScript code to send requests, potentially including sensitive/secret data, off to destinations that the JavaScript project was not intending, which could be a security issue.
Note: This feature is in disabled by default for Fastly Services. Please contact Fastly Support to request the feature be enabled on the Fastly Services which require Dynamic Backends.
Syntax
allowDynamicBackends(enabled)
Parameters
enabled
: boolean- Whether or not to allow Dynamic Backends
Return value
undefined
.
Examples
In this example an implicit Dynamic Backend is created when making the fetch request to https://www.fastly.com/ and the response is then returned to the client.
/// <reference types="@fastly/js-compute" />
import { allowDynamicBackends } from "fastly:experimental";
allowDynamicBackends(true);
async function app() {
// For any request, return the fastly homepage -- without defining a backend!
return fetch('https://www.fastly.com/');
}
addEventListener("fetch", event => event.respondWith(app(event)));