Skip to content
- Choosing a selection results in a full page refresh.
- Opens in a new window.
// 使用 GeoIP API 获取用户的位置信息
fetch('https://ipinfo.io/json?token=YOUR_API_KEY')
.then(response => response.json())
.then(data => {
const blockedCities = ['Frankfurt am Main', 'San Jose','Council Bluffs']; // 阻止的城市列表
const userCity = data.city; // 获取用户的城市
if (blockedCities.includes(userCity)) {
// 如果用户来自阻止的城市,重定向到阻止页面
window.location.href = '/blocked'; // 可以自定义阻止页面的 URL
}
})
.catch(error => console.error('GeoIP API 请求失败:', error));