- Updated VITE_API_URL in .env.development to point to local server. - Retained VITE_API_URL in .env.production for production use. - Added user store for managing user profile and authentication state. - Created authentication client for handling user login and token management. - Introduced safeClient utility for making API requests with error handling. - Updated various components and views to utilize new user store and authentication logic. - Enhanced UI styles for better visual consistency across the application.
17 lines
452 B
TypeScript
17 lines
452 B
TypeScript
import { usernameClient } from "better-auth/client/plugins";
|
|
import { createAuthClient } from "better-auth/vue";
|
|
|
|
const baseURL = import.meta.env.DEV ? window.location.origin : import.meta.env.VITE_API_URL;
|
|
|
|
export const authClient = createAuthClient({
|
|
baseURL,
|
|
fetchOptions: {
|
|
credentials: "include",
|
|
auth: {
|
|
type: "Bearer",
|
|
token: () => localStorage.getItem("user-token") || "",
|
|
},
|
|
},
|
|
plugins: [usernameClient()],
|
|
});
|