Skip to content

Commit 7fe9161

Browse files
committed
fix: make updateLocalEnv compatible with local development
1 parent 836b733 commit 7fe9161

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

scripts/updateLocalEnv.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,29 @@ const prod = JSON.parse(JSON.stringify(yaml.load(file)));
88
const vars = prod.envVars as Record<string, string>;
99

1010
let PUBLIC_CONFIG = "";
11-
Object.entries(vars).forEach(([key, value]) => {
12-
PUBLIC_CONFIG += `${key}=\`${value}\`\n`;
13-
});
11+
12+
Object.entries(vars)
13+
// filter keys used in prod with the proxy
14+
.filter(([key]) => !["XFF_DEPTH", "ADDRESS_HEADER"].includes(key))
15+
.forEach(([key, value]) => {
16+
PUBLIC_CONFIG += `${key}=\`${value}\`\n`;
17+
});
1418

1519
const SECRET_CONFIG =
1620
(fs.existsSync(".env.SECRET_CONFIG")
1721
? fs.readFileSync(".env.SECRET_CONFIG", "utf8")
1822
: process.env.SECRET_CONFIG) ?? "";
1923

2024
// Prepend the content of the env variable SECRET_CONFIG
21-
const full_config = `${PUBLIC_CONFIG}\n${SECRET_CONFIG}`;
25+
let full_config = `${PUBLIC_CONFIG}\n${SECRET_CONFIG}`;
26+
27+
// replace the internal proxy url with the public endpoint
28+
full_config = full_config.replaceAll(
29+
"https://proxy.serverless.api-inference.huggingface.tech",
30+
"https://api-inference.huggingface.co"
31+
);
32+
33+
console.log(full_config);
2234

2335
// Write full_config to .env.local
2436
fs.writeFileSync(".env.local", full_config);

0 commit comments

Comments
 (0)