diff --git a/helpers/strategies/AxiosStrategy.js b/helpers/strategies/AxiosStrategy.js index 583cdcd19..ed84e988b 100644 --- a/helpers/strategies/AxiosStrategy.js +++ b/helpers/strategies/AxiosStrategy.js @@ -12,6 +12,10 @@ export const cancelRunningAxiosRequest = () => { const axiosWithProxy = async (req, { state }) => { try { + console.log({ + ...req, + wantsBinary: true, + }) const { data } = await axios.post( state.postwoman.settings.PROXY_URL || "https://postwoman.apollosoftware.xyz/", { @@ -23,6 +27,10 @@ const axiosWithProxy = async (req, { state }) => { } ) + if (!data.data.success) { + throw new Error(data.data.message || "Proxy Error") + } + if (data.isBinary) { data.data = decodeB64StringToArrayBuffer(data.data) } diff --git a/helpers/strategies/ExtensionStrategy.js b/helpers/strategies/ExtensionStrategy.js index c98204c35..b96737e28 100644 --- a/helpers/strategies/ExtensionStrategy.js +++ b/helpers/strategies/ExtensionStrategy.js @@ -25,11 +25,17 @@ const extensionWithProxy = async (req, { state }) => { }, }) - if (data.isBinary) { - data.data = decodeB64StringToArrayBuffer(data.data) + const parsedData = JSON.parse(data) + + if (!parsedData.data.success) { + throw new Error(parsedData.data.message || "Proxy Error") } - return data + if (parsedData.isBinary) { + parsedData.data = decodeB64StringToArrayBuffer(data.data) + } + + return parsedData } const extensionWithoutProxy = async (req, _store) => {