Archived
Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:4000';
|
||||
|
||||
export const apiClient = axios.create({ baseURL: API_URL });
|
||||
|
||||
export function setAuthToken(token: string | null) {
|
||||
if (token) {
|
||||
apiClient.defaults.headers.common.Authorization = `Bearer ${token}`;
|
||||
localStorage.setItem('dnd_token', token);
|
||||
} else {
|
||||
delete apiClient.defaults.headers.common.Authorization;
|
||||
localStorage.removeItem('dnd_token');
|
||||
}
|
||||
}
|
||||
|
||||
export function getStoredToken(): string | null {
|
||||
return localStorage.getItem('dnd_token');
|
||||
}
|
||||
Reference in New Issue
Block a user