Added proxy error handling code
This commit is contained in:
@@ -12,6 +12,10 @@ export const cancelRunningAxiosRequest = () => {
|
|||||||
|
|
||||||
const axiosWithProxy = async (req, { state }) => {
|
const axiosWithProxy = async (req, { state }) => {
|
||||||
try {
|
try {
|
||||||
|
console.log({
|
||||||
|
...req,
|
||||||
|
wantsBinary: true,
|
||||||
|
})
|
||||||
const { data } = await axios.post(
|
const { data } = await axios.post(
|
||||||
state.postwoman.settings.PROXY_URL || "https://postwoman.apollosoftware.xyz/",
|
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) {
|
if (data.isBinary) {
|
||||||
data.data = decodeB64StringToArrayBuffer(data.data)
|
data.data = decodeB64StringToArrayBuffer(data.data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,17 @@ const extensionWithProxy = async (req, { state }) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (data.isBinary) {
|
const parsedData = JSON.parse(data)
|
||||||
data.data = decodeB64StringToArrayBuffer(data.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) => {
|
const extensionWithoutProxy = async (req, _store) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user