diff --git a/.gitignore b/.gitignore index a547bf3..65d2f2c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ dist-ssr *.njsproj *.sln *.sw? +/.env diff --git a/src/App.tsx b/src/App.tsx index db763ef..961211b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -61,7 +61,7 @@ export function LargeSelect() { queryKey: ['obsidian-metadata'], initialData: [], queryFn: async () => { - const response = await fetch("http://100.115.154.44:9002/metadata") + const response = await fetch("/metadata") const fullData: any[] = await response.json(); return R.sortBy(v => -(v.data.backlinks?.length ?? 0), fullData.map(md => ({ diff --git a/vite.config.ts b/vite.config.ts index 41dd742..12421ad 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,10 +1,21 @@ -import {defineConfig} from 'vite' +import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react-swc' // https://vitejs.dev/config/ -export default defineConfig({ - plugins: [react()], - server: { - host: '0.0.0.0' +export default defineConfig(({ command, mode }) => { + // Load env file based on `mode` in the current working directory. + // Set the third parameter to '' to load all env regardless of the `VITE_` prefix. + const env = loadEnv(mode, process.cwd(), '') + + return { + plugins: [react()], + server: { + host: '0.0.0.0', + proxy: { + '/metadata': { + target: env['OBSIDIAN_BEACHHEAD_SERVER'] + } + } + } } })