fix(agent): add agent header [EE-2433] (#6484)
* fix(agent): add agent header [EE-2433] fix [EE-2433] * fix(containers): reload current endpoint idpull/6511/head
parent
cb804e8813
commit
7d91ab72e1
|
@ -199,8 +199,10 @@ function ContainerServiceFactory($q, Container, LogHelper, $timeout, EndpointPro
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
function withEndpointId(func) {
|
function withEndpointId(func) {
|
||||||
|
return function (...args) {
|
||||||
const endpointId = EndpointProvider.endpointID();
|
const endpointId = EndpointProvider.endpointID();
|
||||||
|
|
||||||
return func.bind(null, endpointId);
|
return func(endpointId, ...args);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,11 @@ const axiosApiInstance = axios.create({ baseURL: 'api' });
|
||||||
export default axiosApiInstance;
|
export default axiosApiInstance;
|
||||||
|
|
||||||
axiosApiInstance.interceptors.request.use(async (config) => {
|
axiosApiInstance.interceptors.request.use(async (config) => {
|
||||||
const newConfig = { ...config };
|
const newConfig = { headers: config.headers || {}, ...config };
|
||||||
|
|
||||||
const jwt = localStorageGet('JWT', '');
|
const jwt = localStorageGet('JWT', '');
|
||||||
if (jwt) {
|
if (jwt) {
|
||||||
newConfig.headers = {
|
newConfig.headers.Authorization = `Bearer ${jwt}`;
|
||||||
Authorization: `Bearer ${jwt}`,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newConfig;
|
return newConfig;
|
||||||
|
@ -31,8 +29,11 @@ export function agentInterceptor(config: AxiosRequestConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const newConfig = { headers: config.headers || {}, ...config };
|
const newConfig = { headers: config.headers || {}, ...config };
|
||||||
|
const target = portainerAgentTargetHeader();
|
||||||
|
if (target) {
|
||||||
|
newConfig.headers['X-PortainerAgent-Target'] = target;
|
||||||
|
}
|
||||||
|
|
||||||
newConfig.headers['X-PortainerAgent-Target'] = portainerAgentTargetHeader();
|
|
||||||
if (portainerAgentManagerOperation()) {
|
if (portainerAgentManagerOperation()) {
|
||||||
newConfig.headers['X-PortainerAgent-ManagerOperation'] = '1';
|
newConfig.headers['X-PortainerAgent-ManagerOperation'] = '1';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue