2020-02-25 02:06:23 +00:00
|
|
|
import axios from "axios"
|
2020-01-14 04:46:31 +00:00
|
|
|
|
2020-01-19 07:07:19 +00:00
|
|
|
const axiosWithProxy = async (req, { state }) => {
|
2020-01-17 18:27:37 +00:00
|
|
|
const { data } = await axios.post(
|
2020-02-26 23:48:24 +00:00
|
|
|
state.postwoman.settings.PROXY_URL || "https://postwoman.apollosoftware.xyz/",
|
2020-01-17 18:27:37 +00:00
|
|
|
req
|
2020-02-24 18:44:50 +00:00
|
|
|
)
|
|
|
|
|
return data
|
|
|
|
|
}
|
2020-01-17 18:27:37 +00:00
|
|
|
|
|
|
|
|
const axiosWithoutProxy = async (req, _store) => {
|
2020-02-24 18:44:50 +00:00
|
|
|
const res = await axios(req)
|
|
|
|
|
return res
|
|
|
|
|
}
|
2020-01-14 04:46:31 +00:00
|
|
|
|
2020-01-17 18:27:37 +00:00
|
|
|
const axiosStrategy = (req, store) => {
|
2020-01-18 09:16:51 +00:00
|
|
|
if (store.state.postwoman.settings.PROXY_ENABLED) {
|
2020-02-24 18:44:50 +00:00
|
|
|
return axiosWithProxy(req, store)
|
2020-01-18 09:16:51 +00:00
|
|
|
}
|
2020-02-24 18:44:50 +00:00
|
|
|
return axiosWithoutProxy(req, store)
|
|
|
|
|
}
|
2020-01-17 18:27:37 +00:00
|
|
|
|
2020-02-24 18:44:50 +00:00
|
|
|
export default axiosStrategy
|