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;
|
||||
|
||||
function withEndpointId(func) {
|
||||
const endpointId = EndpointProvider.endpointID();
|
||||
return function (...args) {
|
||||
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;
|
||||
|
||||
axiosApiInstance.interceptors.request.use(async (config) => {
|
||||
const newConfig = { ...config };
|
||||
const newConfig = { headers: config.headers || {}, ...config };
|
||||
|
||||
const jwt = localStorageGet('JWT', '');
|
||||
if (jwt) {
|
||||
newConfig.headers = {
|
||||
Authorization: `Bearer ${jwt}`,
|
||||
};
|
||||
newConfig.headers.Authorization = `Bearer ${jwt}`;
|
||||
}
|
||||
|
||||
return newConfig;
|
||||
|
@ -31,8 +29,11 @@ export function agentInterceptor(config: AxiosRequestConfig) {
|
|||
}
|
||||
|
||||
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()) {
|
||||
newConfig.headers['X-PortainerAgent-ManagerOperation'] = '1';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue