Revert "Fix updating users via cross-service comms (public API)"
This commit is contained in:
parent
c84c7f9299
commit
74957725dd
|
@ -14,23 +14,12 @@ export function request(ctx?: Ctx, request?: any) {
|
||||||
if (!request.headers) {
|
if (!request.headers) {
|
||||||
request.headers = {}
|
request.headers = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
request.headers[constants.Header.API_KEY] = coreEnv.INTERNAL_API_KEY
|
request.headers[constants.Header.API_KEY] = coreEnv.INTERNAL_API_KEY
|
||||||
} else if (ctx.headers) {
|
if (tenancy.isTenantIdSet()) {
|
||||||
// copy all Budibase utilised headers over - copying everything can have
|
request.headers[constants.Header.TENANT_ID] = tenancy.getTenantId()
|
||||||
// side effects like requests being rejected due to odd content types etc
|
|
||||||
for (let header of Object.values(constants.Header)) {
|
|
||||||
if (ctx.headers[header]) {
|
|
||||||
request.headers[header] = ctx.headers[header]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply tenancy if its available
|
|
||||||
if (tenancy.isTenantIdSet()) {
|
|
||||||
request.headers[constants.Header.TENANT_ID] = tenancy.getTenantId()
|
|
||||||
}
|
|
||||||
if (request.body && Object.keys(request.body).length > 0) {
|
if (request.body && Object.keys(request.body).length > 0) {
|
||||||
request.headers["Content-Type"] = "application/json"
|
request.headers["Content-Type"] = "application/json"
|
||||||
request.body =
|
request.body =
|
||||||
|
@ -40,6 +29,9 @@ export function request(ctx?: Ctx, request?: any) {
|
||||||
} else {
|
} else {
|
||||||
delete request.body
|
delete request.body
|
||||||
}
|
}
|
||||||
|
if (ctx && ctx.headers) {
|
||||||
|
request.headers = ctx.headers
|
||||||
|
}
|
||||||
|
|
||||||
// add x-budibase-correlation-id header
|
// add x-budibase-correlation-id header
|
||||||
logging.correlation.setHeader(request.headers)
|
logging.correlation.setHeader(request.headers)
|
||||||
|
@ -62,7 +54,7 @@ async function checkResponse(
|
||||||
}
|
}
|
||||||
const msg = `Unable to ${errorMsg} - ${responseErrorMessage}`
|
const msg = `Unable to ${errorMsg} - ${responseErrorMessage}`
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
ctx.throw(response.status || 500, msg)
|
ctx.throw(msg, response.status)
|
||||||
} else {
|
} else {
|
||||||
throw msg
|
throw msg
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue