diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..52e68eb --- /dev/null +++ b/.env.sample @@ -0,0 +1,4 @@ +# ============================================================================= +# WEBUI +# ============================================================================= +VITE_API_URL=http://localhost:8080 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 76add87..a0d218e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -dist \ No newline at end of file +dist +.env \ No newline at end of file diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx index 7b8fae9..164c192 100644 --- a/src/contexts/AuthContext.tsx +++ b/src/contexts/AuthContext.tsx @@ -33,7 +33,7 @@ export const AuthProvider: React.FC = ({ children }) => { try { setLoading(true); - const response = await fetch('https://capyrpi.org/api/v1/auth/me', { + const response = await fetch(import.meta.env.VITE_API_URL + '/api/v1/auth/me', { headers: { Accept: 'application/json' }, credentials: 'include', }); @@ -62,14 +62,14 @@ export const AuthProvider: React.FC = ({ children }) => { const login = (provider: 'google' | 'microsoft'): void => { const url = provider === 'google' - ? 'https://capyrpi.org/api/v1/auth/google' - : 'https://capyrpi.org/api/v1/auth/microsoft'; + ? import.meta.env.VITE_API_URL + '/api/v1/auth/google' + : import.meta.env.VITE_API_URL + '/api/v1/auth/microsoft'; window.open(url, '_blank'); const pollInterval = setInterval(async () => { try { - const response = await fetch('https://capyrpi.org/api/v1/auth/me', { + const response = await fetch(import.meta.env.VITE_API_URL + '/api/v1/auth/me', { headers: { Accept: 'application/json' }, credentials: 'include', }); @@ -92,7 +92,7 @@ export const AuthProvider: React.FC = ({ children }) => { }; const logout = async (): Promise => { try { - await fetch('https://capyrpi.org/api/v1/auth/logout', { + await fetch(import.meta.env.VITE_API_URL + '/api/v1/auth/logout', { method: 'POST', });