feat: Next.js 14 web admin scaffold — auth, sidebar, dashboard, placeholders

This commit is contained in:
Forge
2026-03-25 08:23:25 +08:00
parent dc01eac449
commit 310a9453de
37 changed files with 2755 additions and 292 deletions

29
lib/api.ts Normal file
View File

@@ -0,0 +1,29 @@
import axios from 'axios';
export const api = axios.create({
baseURL: 'https://fiberops-api.juankibin.space',
});
api.interceptors.request.use((config) => {
if (typeof window !== 'undefined') {
const auth = JSON.parse(localStorage.getItem('fiberops_auth') || '{}');
if (auth.state?.accessToken) {
config.headers.Authorization = `Bearer ${auth.state.accessToken}`;
config.headers['x-tenant-slug'] = auth.state.tenantSlug;
}
}
return config;
});
api.interceptors.response.use(
(r) => r,
(err) => {
if (err.response?.status === 401) {
if (typeof window !== 'undefined') {
localStorage.removeItem('fiberops_auth');
window.location.href = '/login';
}
}
return Promise.reject(err);
}
);