|
@@ -9,13 +9,15 @@ xhr.addEventListener("loadend", async function (e){
|
|
|
let responseObj = JSON.parse(this.response);
|
|
|
let ip = responseObj.ip;
|
|
|
let regionData = await ipToRegion(ip);
|
|
|
+ let country = window.location.protocol === 'https:' ? regionData.country_name : regionData.geoplugin_countryName
|
|
|
if (window.regionMap[regionData.geoplugin_countryName]) {
|
|
|
window.location.href = window.regionMap[regionData.geoplugin_countryName]
|
|
|
}
|
|
|
});
|
|
|
xhr.send();
|
|
|
async function ipToRegion(ip) {
|
|
|
- const response = await fetch(`http://www.geoplugin.net/json.gp?ip=${ip}`);
|
|
|
+ let url = window.location.protocol === 'https:' ? `/ipdata.php?ip=${ip}` : `http://www.geoplugin.net/json.gp?ip=${ip}`
|
|
|
+ const response = await fetch(url);
|
|
|
const data = await response.json();
|
|
|
return data;
|
|
|
}
|