Skip to content

Commit 95c2fb5

Browse files
committed
security: Remove API keys from config.js, block sensitive files in nginx
1 parent ecaded7 commit 95c2fb5

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎nginx.conf‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ server {
2020
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
2121
}
2222

23+
# SECURITY: Block access to sensitive files
24+
location ~* \.(md|txt|env|log|yml|yaml|json|lock|git|gitignore|dockerignore)$ {
25+
deny all;
26+
return 404;
27+
}
28+
29+
# SECURITY: Block hidden files and directories
30+
location ~ /\. {
31+
deny all;
32+
return 404;
33+
}
34+
2335
location / {
2436
try_files $uri $uri/ /index.html;
2537
}

‎public/config.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
// Runtime configuration for DebateLab
2+
// Note: API keys are stored securely in the Supabase Edge Function
3+
// This file only contains non-sensitive frontend configuration
14
window.env = {
2-
VITE_OPENAI_API_KEY: "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",
3-
VITE_GOOGLE_API_KEY: "AIzaSyBeO-POlfAiaRECM6aFahxtsvVD5qRlUz4",
4-
VITE_ANTHROPIC_API_KEY: "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"
5+
// No API keys needed - all AI calls go through the authenticated Edge Function
56
};

‎supabase/functions/ai/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const PROMPT_INJECTION_PATTERNS = [
5555

5656
function sanitizePromptInput(input: string, fieldName: string): { sanitized: string } | { rejected: string } {
5757
if (typeof input !== "string") return { sanitized: "" };
58+
// eslint-disable-next-line no-control-regex
5859
let sanitized = input.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, "");
5960
for (const pattern of PROMPT_INJECTION_PATTERNS) {
6061
if (pattern.test(sanitized)) {

0 commit comments

Comments
 (0)