feat: add drawer

This commit is contained in:
2024-11-12 04:43:59 +07:00
parent 38e81049a1
commit 8159b65605
10 changed files with 168 additions and 23 deletions
+9 -4
View File
@@ -1,13 +1,18 @@
import { getCurrentServer } from "@/stores/app";
import authStore from "@/stores/auth";
import { QueryClient } from "@tanstack/react-query";
import { ofetch } from "ofetch";
export const BASE_API_URL = process.env.EXPO_PUBLIC_API_URL || ""; //"http://10.0.0.100:3000";
export const BASE_WS_URL = BASE_API_URL.replace("http", "ws");
const api = ofetch.create({
baseURL: BASE_API_URL,
onRequest: (config) => {
const server = getCurrentServer();
if (!server) {
throw new Error("No server selected");
}
// set server url
config.options.baseURL = server.url;
const authToken = authStore.getState().token;
if (authToken) {
config.options.headers.set("Authorization", `Bearer ${authToken}`);