@forge/tunnel

7.1.2-next.37.1.2-next.3-experimental-e9e08bb
out/servers/dev-server.js
~out/servers/dev-server.jsModified
+18−2
Index: package/out/servers/dev-server.js
===================================================================
--- package/out/servers/dev-server.js
+++ package/out/servers/dev-server.js
@@ -1,7 +1,7 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
-exports.LocalDevelopmentServer = exports.TunnelInvocationValidationError = void 0;
+exports.LocalDevelopmentServer = exports.getLocalStorageVariables = exports.TunnelInvocationValidationError = void 0;
 exports.stopServer = stopServer;
 const tslib_1 = require("tslib");
 const express_1 = tslib_1.__importDefault(require("express"));
 const bundler_1 = require("@forge/bundler");
@@ -12,8 +12,21 @@
 const ari_1 = require("@forge/util/packages/ari");
 class TunnelInvocationValidationError extends cli_shared_1.UserError {
 }
 exports.TunnelInvocationValidationError = TunnelInvocationValidationError;
+const LOCAL_STORAGE_ENVIRONMENT_KEYS = [
+    'FORGE_LOCAL_STORAGE',
+    'FORGE_LOCAL_KVS_URL',
+    'FORGE_LOCAL_SQL_URL',
+    'FORGE_LOCAL_STORAGE_APP_ID',
+    'FORGE_LOCAL_STORAGE_ENVIRONMENT_ID',
+    'FORGE_LOCAL_STORAGE_INSTALLATION_ID'
+];
+const getLocalStorageVariables = () => LOCAL_STORAGE_ENVIRONMENT_KEYS.flatMap((key) => {
+    const value = process.env[key];
+    return value === undefined ? [] : [{ key, value, secure: false }];
+});
+exports.getLocalStorageVariables = getLocalStorageVariables;
 async function stopServer(server) {
     if (!server) {
         return;
     }
@@ -89,9 +102,12 @@
         this.onFatalError = handler;
     }
     handleInvocation = async (req, res) => {
         const request = req.body;
-        const envVars = (0, runtime_1.getUserVars)();
+        const envVarsByKey = new Map((0, runtime_1.getUserVars)().map((variable) => [variable.key, variable]));
+        for (const variable of (0, exports.getLocalStorageVariables)())
+            envVarsByKey.set(variable.key, variable);
+        const envVars = [...envVarsByKey.values()];
         request.variables?.forEach((item) => {
             if (!envVars.find((i) => i.key === item.key)) {
                 envVars.push(item);
             }