feat: custom request headers

This commit is contained in:
chenos 2022-04-24 15:41:30 +08:00
parent bc293b8fef
commit 85882f7c7a

View File

@ -59,6 +59,7 @@ export class APIClient {
authMiddleware() { authMiddleware() {
this.axios.interceptors.request.use((config) => { this.axios.interceptors.request.use((config) => {
const token = localStorage.getItem(this.tokenKey); const token = localStorage.getItem(this.tokenKey);
config.headers['X-Hostname'] = window.location.hostname;
if (token) { if (token) {
config.headers['Authorization'] = `Bearer ${token}`; config.headers['Authorization'] = `Bearer ${token}`;
} }