feat: 更新 API 客户端配置,使用环境变量设置 baseURL;优化头像组件样式
This commit is contained in:
@@ -5,16 +5,18 @@ import { toastController } from "@ionic/vue";
|
||||
import { i18n } from "@/locales";
|
||||
import { useMocks } from "@/mocks";
|
||||
|
||||
const client = treaty<App>(window.location.origin, {
|
||||
const baseURL = import.meta.env.DEV ? window.location.origin : import.meta.env.VITE_API_URL;
|
||||
|
||||
const client = treaty<App>(baseURL, {
|
||||
fetch: {
|
||||
credentials: "include",
|
||||
},
|
||||
headers() {
|
||||
const token = localStorage.getItem("user-token") || "";
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": token ? `Bearer ${token}` : "",
|
||||
};
|
||||
const headers = new Headers();
|
||||
headers.append("Content-Type", "application/json");
|
||||
headers.append("Authorization", token ? `Bearer ${token}` : "");
|
||||
return headers;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user