add slug in header requests
This commit is contained in:
@@ -101,7 +101,17 @@ axiosInstance.interceptors.request.use(async function (config) {
|
||||
const tokenValue = await getToken();
|
||||
const token = tokenValue ? tokenValue : "";
|
||||
|
||||
let slug = "dmenu";
|
||||
if (typeof window !== "undefined") {
|
||||
const pathname = window.location.pathname;
|
||||
const pathParts = pathname.split("/").filter(Boolean);
|
||||
if (pathParts.length > 0) {
|
||||
slug = pathParts[0];
|
||||
}
|
||||
}
|
||||
|
||||
config.headers.Authorization = "Bearer " + token;
|
||||
config.headers["X-SLUG"] = slug;
|
||||
|
||||
return config;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user