Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Moved proxy code to be handled in each strategy

Andrew Bastin2a51ec6d9f41
diff --git a/functions/network.js b/functions/network.js
index 7ed233cf8..a2c885be5 100644
--- a/functions/network.js
+++ b/functions/network.js
@@ -1,5 +1,4 @@
import AxiosStrategy from "./strategies/AxiosStrategy";
-import ProxyStrategy from "./strategies/ProxyStrategy";
import FirefoxStrategy from "./strategies/FirefoxStrategy";
@@ -10,10 +9,6 @@ const runAppropriateStrategy = (req, store) => {
return FirefoxStrategy(req, store);
}
- if (store.state.postwoman.settings.PROXY_ENABLED) {
- return ProxyStrategy(req, store);
- }
-
return AxiosStrategy(req, store);
}
diff --git a/functions/strategies/AxiosStrategy.js b/functions/strategies/AxiosStrategy.js
index 9bef30aef..885ed2f1e 100644
--- a/functions/strategies/AxiosStrategy.js
+++ b/functions/strategies/AxiosStrategy.js
@@ -1,8 +1,23 @@
import axios from "axios";
-const axiosStrategy = async (req, _store) => {
+const axiosWithProxy = async (req, store) => {
+ const { data } = await axios.post(
+ store.state.postwoman.settings.PROXY_URL ||
+ "https://postwoman.apollotv.xyz/",
+ req
+ );
+ return data;
+}
+
+const axiosWithoutProxy = async (req, _store) => {
const res = await axios(req);
return res;
};
+const axiosStrategy = (req, store) => {
+ if (store.state.postwoman.settings.PROXY_ENABLED)
+ return axiosWithProxy(req, store);
+ else return axiosWithoutProxy(req, store);
+}
+
export default axiosStrategy;
diff --git a/functions/strategies/ProxyStrategy.js b/functions/strategies/ProxyStrategy.js
deleted file mode 100644
index 0b6f50b0f..000000000
--- a/functions/strategies/ProxyStrategy.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import axios from "axios";
-
-const proxyStrategy = async (req, store) => {
- const { data } = await axios.post(
- store.state.postwoman.settings.PROXY_URL ||
- "https://postwoman.apollotv.xyz/",
- req
- );
- return data;
-};
-
-export default proxyStrategy;