next-lib requestGet fix & refactoring
This commit is contained in:
1 parent
44d2ba7bff
commit
f78deffbd5
1 file changed
+7
-5
+7
-5
@@ -1,3 +1,5 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
export async function requestGet(url, defaultResponse) {
|
export async function requestGet(url, defaultResponse) {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get(url)
|
const res = await axios.get(url)
|
||||||
@@ -15,14 +17,14 @@ export function createApiUrl(req, path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function absoluteUrl(req, defaultLocalhost) {
|
function absoluteUrl(req, defaultLocalhost) {
|
||||||
var protocol = 'https:';
|
let protocol = 'https:'
|
||||||
var host = req
|
let host = req
|
||||||
? (req.headers['x-forwarded-host'] || req.headers['host'])
|
? (req.headers['x-forwarded-host'] || req.headers['host'])
|
||||||
: window.location.host;
|
: window.location.host
|
||||||
host = host || defaultLocalhost
|
host = host || defaultLocalhost
|
||||||
if (host.indexOf('localhost') > -1) {
|
if (host.indexOf('localhost') > -1) {
|
||||||
if (defaultLocalhost) host = defaultLocalhost;
|
if (defaultLocalhost) host = defaultLocalhost
|
||||||
protocol = 'http:';
|
protocol = 'http:'
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in new issue
Block a user