@forge/tunnel
7.1.2-next.37.1.2-next.3-experimental-e9e08bb
out/sandbox/sandbox-runner.js~
out/sandbox/sandbox-runner.jsModified+13
Index: package/out/sandbox/sandbox-runner.js
===================================================================
--- package/out/sandbox/sandbox-runner.js
+++ package/out/sandbox/sandbox-runner.js
@@ -1,8 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const [_nodeBinary, _thisScript, fileName, handlerName] = process.argv;
global.__forge_tunnel__ = true;
+if (process.env.FORGE_LOCAL_STORAGE === '1') {
+ const nativeFetch = globalThis.fetch.bind(globalThis);
+ const allowedOrigins = new Set([process.env.FORGE_LOCAL_KVS_URL, process.env.FORGE_LOCAL_SQL_URL]
+ .filter((url) => Boolean(url))
+ .map((url) => new URL(url).origin));
+ global.__forge_local_fetch__ = async (input, init) => {
+ const target = new URL(input instanceof Request ? input.url : input);
+ if (!allowedOrigins.has(target.origin)) {
+ throw new Error(`Local Forge storage fetch blocked for unconfigured origin: ${target.origin}`);
+ }
+ return nativeFetch(input, init);
+ };
+}
const handler = require(fileName)[handlerName];
process.on('message', async ({ lambdaEvent, tunnelContext: { requestId, deadline } }) => {
const lambdaContext = {
awsRequestId: requestId,