From 107e45458967a3db75134d880a68d548c48e62ae Mon Sep 17 00:00:00 2001 From: Vadim Date: Wed, 25 Mar 2026 21:58:45 +0300 Subject: [PATCH] wip --- .env | 3 ++- .env.production | 2 ++ src/stores/auth.ts | 5 ++++- src/stores/sockets.ts | 2 +- vite.config.ts | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .env.production diff --git a/.env b/.env index e866fa6..02f394b 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ -BASE_URL=https://chat.madsky.ru \ No newline at end of file +VITE_API_URL=https://chat.madsky.ru +VITE_WS_URL=ws://localhost:3000 \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..02f394b --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +VITE_API_URL=https://chat.madsky.ru +VITE_WS_URL=ws://localhost:3000 \ No newline at end of file diff --git a/src/stores/auth.ts b/src/stores/auth.ts index 28e08dd..f1974b2 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -7,6 +7,9 @@ export const useAuthStore = defineStore('auth', () => { const me = ref() async function login(email: string) { + const baseUrl = import.meta.env.VITE_API_URL + console.log(baseUrl) + try { const options = { method: 'POST', @@ -15,7 +18,7 @@ export const useAuthStore = defineStore('auth', () => { }, body: JSON.stringify({ email: email }), } - const res = await fetch('http://localhost:5173/api/login', options) + const res = await fetch(baseUrl + '/api/login', options) if (res.ok) { const data: { accessToken: string; refreshToken: string } = await res.json() diff --git a/src/stores/sockets.ts b/src/stores/sockets.ts index 7a4d8a3..3b49c01 100644 --- a/src/stores/sockets.ts +++ b/src/stores/sockets.ts @@ -32,7 +32,7 @@ export enum COMMAND { } export const useSocketsStore = defineStore('sockets', () => { - const url = 'ws://localhost:3000/ws' + const url = import.meta.env.WS_URL + '/ws' const authStore = useAuthStore() const chatsStore = useChatsStore() diff --git a/vite.config.ts b/vite.config.ts index 605bceb..0247847 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,7 +14,7 @@ export default defineConfig({ }, }, server: { - host: true, + // host: true, port: 5173, strictPort: true, proxy: {