Added proposed binary proxy response code

This commit is contained in:
Andrew Bastin
2020-06-28 02:50:14 -04:00
parent 8ea64e2224
commit 7778202439
3 changed files with 52 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
import axios from "axios"
// import { isJSONContentType } from "../utils/contenttypes"
import { decodeB64StringToArrayBuffer } from "../utils/b64"
let cancelSource = axios.CancelToken.source()
@@ -14,11 +14,19 @@ const axiosWithProxy = async (req, { state }) => {
try {
const { data } = await axios.post(
state.postwoman.settings.PROXY_URL || "https://postwoman.apollosoftware.xyz/",
req,
{
...req,
wantsBinary: true,
},
{
cancelToken: cancelSource.token,
}
)
if (data.isBinary) {
data.data = decodeB64StringToArrayBuffer(data.data)
}
return data
} catch (e) {
// Check if the throw is due to a cancellation