Skip to content

Commit

Permalink
Fix incorrect Axios auth usage
Browse files Browse the repository at this point in the history
The Auth being injected into Axios was not defined correctly and thus not being applied
The auth credentials need to be defined inside an auth object inside the header object

https://axios-http.com/docs/req_config
  • Loading branch information
BMartinos committed May 20, 2024
1 parent 52a1880 commit 73b64c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/lib/tools/cacheFHIR.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const updateESCompilationsRate = callback => {
username: config.get('elastic:username'),
password: config.get('elastic:password'),
};
axios.put(url, body, auth).then(response => {
axios.put(url, body, { auth }).then(response => {
if (response.status > 199 && response.status < 299) {
logger.info('maximum compilation rate updated successfully');
return callback(false);
Expand Down Expand Up @@ -287,7 +287,7 @@ const createESIndex = (name, IDFields, reportFields, callback) => {
username: config.get('elastic:username'),
password: config.get('elastic:password'),
};
axios.put(url, settings, auth).then(response => {
axios.put(url, settings, { auth }).then(response => {
if (response.status >= 200 && response.status <= 299) {
logger.info('Analyzer created successfully');
return callback(null);
Expand Down Expand Up @@ -345,7 +345,7 @@ const createESIndex = (name, IDFields, reportFields, callback) => {
username: config.get('elastic:username'),
password: config.get('elastic:password'),
};
axios.put(url, mapping, auth).then(response => {
axios.put(url, mapping, { auth }).then(response => {
if (response.status >= 200 && response.status <= 299) {
logger.info('Mappings added successfully into elasticsearch');
return callback(null);
Expand Down Expand Up @@ -389,7 +389,7 @@ const updateESDocument = (id, index, record, callback) => {
username: config.get('elastic:username'),
password: config.get('elastic:password')
};
axios.post(url, record, auth).then(response => {
axios.post(url, record, { auth }).then(response => {
logger.info(response.data);
if (response.data._shards.failed) {
logger.warn('Transaction failed, rerunning again');
Expand Down

0 comments on commit 73b64c4

Please sign in to comment.