Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: address placeholder cleanup reviews

Tindee61c13c918
diff --git a/apps/web/env.sh b/apps/web/env.sh
index 617f2994e..6fcbdbb2b 100644
--- a/apps/web/env.sh
+++ b/apps/web/env.sh
@@ -55,14 +55,12 @@ for key in $(env | grep '^KANEO_' | grep -v 'KANEO_API_URL\|KANEO_CLIENT_URL' |
fi
done
-# Empty any remaining quoted `KANEO_*` placeholder whose env var was left unset.
+# Empty the quoted Turnstile placeholder when its env var was left unset.
# Without this, the literal placeholder stays in the bundle and is read by
# the frontend as a truthy string — which broke self-hosted signup when
-# KANEO_TURNSTILE_SITE_KEY was left unset (issue #1304). Apply to any future
-# runtime-substituted flag so the same trap doesn't recur.
+# KANEO_TURNSTILE_SITE_KEY was left unset (issue #1304).
echo "Stripping unset KANEO_* placeholders..."
find /usr/share/nginx/html -type f \( -name "*.js" -o -name "*.css" \) \
- -exec grep -lE '[`"'"'"']KANEO_[A-Z_]+[`"'"'"']' {} \; \
- | xargs -r sed -i -E 's#[`"'"'"']KANEO_[A-Z_]+[`"'"'"']#""#g'
+ -exec sed -i -E 's#[`"'"'"']KANEO_TURNSTILE_SITE_KEY[`"'"'"']#""#g' {} +
echo "✅ Environment variable replacement complete"
diff --git a/apps/web/src/env.test.ts b/apps/web/src/env.test.ts
index 79a2e6fd2..651ab7afe 100644
--- a/apps/web/src/env.test.ts
+++ b/apps/web/src/env.test.ts
@@ -1,17 +1,19 @@
import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
-import path from "node:path";
+import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
-const placeholderPattern = "[`\\\"']KANEO_[A-Z_]+[`\\\"']";
+const placeholderPattern = "[`\\\"']KANEO_TURNSTILE_SITE_KEY[`\\\"']";
+const turnstilePlaceholder = "KANEO_TURNSTILE_SITE_KEY";
describe("runtime environment replacement", () => {
it("strips unset placeholders regardless of the quote emitted by the bundler", () => {
const bundle = [
- 'const doubleQuoted = "KANEO_DOUBLE_QUOTED";',
- "const singleQuoted = 'KANEO_SINGLE_QUOTED';",
- "const templateLiteral = `KANEO_TEMPLATE_LITERAL`;",
- 'const configured = "https://example.com";',
+ `const doubleQuoted = "${turnstilePlaceholder}";`,
+ `const singleQuoted = '${turnstilePlaceholder}';`,
+ `const templateLiteral = \`${turnstilePlaceholder}\`;`,
+ `const required = "KANEO_API_URL";`,
+ `const configured = "https://example.com";`,
].join("\n");
const result = execFileSync("sed", ["-E", `s#${placeholderPattern}#""#g`], {
@@ -19,21 +21,22 @@ describe("runtime environment replacement", () => {
encoding: "utf8",
});
- expect(result).not.toMatch(/KANEO_[A-Z_]+/);
- expect(result).toContain('const doubleQuoted = "";');
- expect(result).toContain('const singleQuoted = "";');
- expect(result).toContain('const templateLiteral = "";');
- expect(result).toContain('const configured = "https://example.com";');
+ expect(result).not.toContain("KANEO_TURNSTILE_SITE_KEY");
+ expect(result).toContain(`const required = "KANEO_API_URL";`);
+ expect(result).toContain(`const doubleQuoted = "";`);
+ expect(result).toContain(`const singleQuoted = "";`);
+ expect(result).toContain(`const templateLiteral = "";`);
+ expect(result).toContain(`const configured = "https://example.com";`);
});
it("uses the quote-agnostic pattern in the container entrypoint", () => {
const entrypoint = readFileSync(
- path.resolve(import.meta.dirname, "../env.sh"),
+ resolve(import.meta.dirname, "../env.sh"),
"utf8",
);
expect(entrypoint).toContain(
- `sed -i -E 's#[\`"'"'"']KANEO_[A-Z_]+[\`"'"'"']#""#g'`,
+ `sed -i -E 's#[\`"'"'"']KANEO_TURNSTILE_SITE_KEY[\`"'"'"']#""#g' {} +`,
);
});
});