Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion worker/config/custom-environment-variables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default {
defaultLimits: {
processingsSeconds: 'DEFAULT_LIMITS_PROCESSINGS_SECONDS'
},
getFromPrivateDataFairUrl: 'GET_FROM_PRIVATE_DATA_FAIR_URL',
mails: {
transport: {
__name: 'MAILS_TRANSPORT',
Expand Down
1 change: 0 additions & 1 deletion worker/config/default.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default {
processingsSeconds: -1
},
privateDataFairUrl: null,
getFromPrivateDataFairUrl: false,
mails: {
// transport is a full configuration object for createTransport of nodemailer
// cf https://nodemailer.com/smtp/
Expand Down
3 changes: 0 additions & 3 deletions worker/config/type/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
}
}
},
"getFromPrivateDataFairUrl": {
"type": "boolean"
},
"mails": {
"type": "object",
"properties": {
Expand Down
13 changes: 3 additions & 10 deletions worker/src/task/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const getAxiosInstance = (processing: Processing, log: LogFunctions) => {
if (account.departmentName) account.departmentName = encodeURIComponent(account.departmentName)
privateHeaders['x-account'] = JSON.stringify(account)
}
privateHeaders['x-processing'] = JSON.stringify({ _id: processing._id, title: encodeURIComponent(processing.title) })

const axiosInstance = axios.create({
// this is necessary to prevent excessive memory usage during large file uploads, see https://github.com/axios/axios/issues/1045
Expand All @@ -45,15 +44,9 @@ export const getAxiosInstance = (processing: Processing, log: LogFunctions) => {
const isDataFairUrl = cfg.url.startsWith(config.dataFairUrl)
if (isDataFairUrl) Object.assign(cfg.headers, privateHeaders)

// use private data fair url if specified to prevent leaving internal infrastructure
// except from GET requests so that they still appear in metrics
// except if config.getFromPrivateDataFairUrl is set to true, then all requests are sent to the private url
const usePrivate =
config.privateDataFairUrl &&
isDataFairUrl &&
(config.getFromPrivateDataFairUrl || ['post', 'put', 'delete', 'patch'].includes(cfg.method || ''))
if (usePrivate) {
cfg.url = cfg.url.replace(config.dataFairUrl, config.privateDataFairUrl!)
// always route data-fair requests through the private url to stay within internal infrastructure
if (isDataFairUrl && config.privateDataFairUrl) {
cfg.url = cfg.url.replace(config.dataFairUrl, config.privateDataFairUrl)
cfg.headers.host = new URL(config.dataFairUrl).host
}
return cfg
Expand Down
Loading