Skip to content

Commit 8083c2b

Browse files
committed
Update readme
1 parent 9ce1f37 commit 8083c2b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/lib/wordlistLoader.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const cache: WordlistCache = {
1616
error: null
1717
}
1818

19-
const BACKEND_URL = import.meta.env.VITE_BACKEND_URL || 'http://localhost:4000'
19+
const API_BASE = (import.meta as any).env?.VITE_API_BASE || ''
20+
const apiUrl = (path: string) => (API_BASE ? `${API_BASE.replace(/\/$/, '')}${path}` : path)
2021

2122
/**
2223
* Fetch word lists from backend or use local fallback.
@@ -46,11 +47,11 @@ export async function getWordLists(): Promise<{ answers: string[]; allowed: stri
4647
try {
4748
// Try to fetch from backend
4849
const [answersRes, allowedRes] = await Promise.all([
49-
fetch(`${BACKEND_URL}/wordlists/answers.json`, {
50+
fetch(apiUrl(`/wordlists/answers.json`), {
5051
signal: AbortSignal.timeout(5000),
5152
headers: { 'Accept': 'application/json' }
5253
}),
53-
fetch(`${BACKEND_URL}/wordlists/allowed.json`, {
54+
fetch(apiUrl(`/wordlists/allowed.json`), {
5455
signal: AbortSignal.timeout(5000),
5556
headers: { 'Accept': 'application/json' }
5657
})
@@ -63,8 +64,8 @@ export async function getWordLists(): Promise<{ answers: string[]; allowed: stri
6364
])
6465

6566
// Validate data structure
66-
if (Array.isArray(answers) && Array.isArray(allowed) &&
67-
answers.length > 0 && allowed.length > 0) {
67+
if (Array.isArray(answers) && Array.isArray(allowed) &&
68+
answers.length > 0 && allowed.length > 0) {
6869
cache.answers = answers
6970
cache.allowed = allowed
7071
cache.loading = false

0 commit comments

Comments
 (0)