Add environment variable for API URL; update TypeScript configuration to include vite-env; refactor API client to use environment variable; modify timestamp fields in database schemas to include timezone support
This commit is contained in:
@@ -0,0 +1 @@
|
||||
VITE_API_URL=http://localhost:3000
|
||||
@@ -2,7 +2,7 @@ import ky from "ky";
|
||||
|
||||
// Базовый API клиент
|
||||
export const api = ky.create({
|
||||
prefixUrl: "http://localhost:3000",
|
||||
prefixUrl: import.meta.env.VITE_API_URL,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
@@ -11,6 +11,7 @@ export const api = ky.create({
|
||||
(request) => {
|
||||
// Автоматически добавляем токен из localStorage если есть
|
||||
const token = localStorage.getItem("authToken");
|
||||
|
||||
if (token) {
|
||||
request.headers.set("Authorization", `Bearer ${token}`);
|
||||
}
|
||||
|
||||
@@ -24,5 +24,5 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": ["src", "vite-env.d.ts"]
|
||||
}
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_URL: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
Reference in New Issue
Block a user