security hardening
This commit is contained in:
@@ -6,22 +6,6 @@ export const api = axios.create({
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
const token = window.localStorage.getItem('incusBackupApiToken') || import.meta.env.VITE_API_TOKEN;
|
||||
if (token) {
|
||||
api.defaults.headers.common.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
export function setApiToken(tokenValue) {
|
||||
const token = String(tokenValue || '');
|
||||
if (token) {
|
||||
window.localStorage.setItem('incusBackupApiToken', token);
|
||||
api.defaults.headers.common.Authorization = `Bearer ${token}`;
|
||||
return;
|
||||
}
|
||||
window.localStorage.removeItem('incusBackupApiToken');
|
||||
delete api.defaults.headers.common.Authorization;
|
||||
}
|
||||
|
||||
export function errorMessage(error) {
|
||||
return error.response?.data?.error || error.message || 'Request failed.';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user