🐛 Fixed url params serializing for OAuth1 requests (#2381)

This commit is contained in:
Omar Ajoue 2021-10-28 18:09:25 +02:00 committed by GitHub
parent c97ceba86d
commit e39678b54f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,6 +86,12 @@ import {
axios.defaults.timeout = 300000; axios.defaults.timeout = 300000;
// Prevent axios from adding x-form-www-urlencoded headers by default // Prevent axios from adding x-form-www-urlencoded headers by default
axios.defaults.headers.post = {}; axios.defaults.headers.post = {};
axios.defaults.paramsSerializer = (params) => {
if (params instanceof URLSearchParams) {
return params.toString();
}
return stringify(params, { arrayFormat: 'indices' });
};
const requestPromiseWithDefaults = requestPromise.defaults({ const requestPromiseWithDefaults = requestPromise.defaults({
timeout: 300000, // 5 minutes timeout: 300000, // 5 minutes
@ -413,6 +419,7 @@ async function parseRequestObject(requestObject: IDataObject) {
if ( if (
requestObject.json !== false && requestObject.json !== false &&
axiosConfig.data !== undefined && axiosConfig.data !== undefined &&
axiosConfig.data !== '' &&
!(axiosConfig.data instanceof Buffer) && !(axiosConfig.data instanceof Buffer) &&
!allHeaders.some((headerKey) => headerKey.toLowerCase() === 'content-type') !allHeaders.some((headerKey) => headerKey.toLowerCase() === 'content-type')
) { ) {
@ -462,6 +469,11 @@ async function proxyRequestToAxios(
axiosConfig = Object.assign(axiosConfig, await parseRequestObject(configObject)); axiosConfig = Object.assign(axiosConfig, await parseRequestObject(configObject));
Logger.debug('Proxying request to axios', {
originalConfig: configObject,
parsedConfig: axiosConfig,
});
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios(axiosConfig) axios(axiosConfig)
.then((response) => { .then((response) => {