next-lib requestGet fix & refactoring

This commit is contained in:
tmshv committed 2019-10-13 16:13:09 +03:00
1 parent 44d2ba7bff
commit f78deffbd5
1 file changed
+7 -5
+7 -5
View File
@@ -1,3 +1,5 @@
import axios from 'axios'
export async function requestGet(url, defaultResponse) {
try {
const res = await axios.get(url)
@@ -15,14 +17,14 @@ export function createApiUrl(req, path) {
}
function absoluteUrl(req, defaultLocalhost) {
var protocol = 'https:';
var host = req
let protocol = 'https:'
let host = req
? (req.headers['x-forwarded-host'] || req.headers['host'])
: window.location.host;
: window.location.host
host = host || defaultLocalhost
if (host.indexOf('localhost') > -1) {
if (defaultLocalhost) host = defaultLocalhost;
protocol = 'http:';
if (defaultLocalhost) host = defaultLocalhost
protocol = 'http:'
}
return {