diff --git a/docker-compose.yaml b/docker-compose.yaml index b702b4e..aab8f28 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,6 +16,8 @@ services: dockerfile: app.dockerfile environment: - SEARXNG_API_URL=http://searxng:8080 + env_file: + - .env ports: - 3000:3000 networks: diff --git a/src/lib/config.ts b/src/lib/config.ts index ac02f82..615dc4a 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -40,10 +40,13 @@ type RecursivePartial = { [P in keyof T]?: RecursivePartial; }; -const loadConfig = () => - toml.parse( - fs.readFileSync(path.join(process.cwd(), `${configFileName}`), 'utf-8'), - ) as any as Config; +const loadConfig = () => { + const configPath = path.join(process.cwd(), configFileName); + if (!fs.existsSync(configPath) || fs.lstatSync(configPath).isDirectory()) { + return {} as Config; + } + return toml.parse(fs.readFileSync(configPath, 'utf-8')) as any as Config; +}; const getEnvVar = (key: string): string | undefined => { return process.env[key]; @@ -88,7 +91,7 @@ export const getGeminiApiKey = () => getConfigValue(['MODELS', 'GEMINI', 'API_KEY'], ''); export const getSearxngApiEndpoint = () => - getConfigValue(['API_ENDPOINTS', 'SEARXNG'], ''); + process.env.SEARXNG_API_URL || getConfigValue(['API_ENDPOINTS', 'SEARXNG'], ''); export const getOllamaApiEndpoint = () => getConfigValue(['MODELS', 'OLLAMA', 'API_URL'], 'http://localhost:11434');