我正在尝试在我的网站上添加代码以获取用户的IP地址。我正在使用带有axios的react(mobx/mst)。
getIpAddress: flow(function*() {
const response = yield axios.get('http://api.ipify.org/?format=text');
self.ipAddress = response.data;
})
Access to XMLHttpRequest at 'http://api.ipify.org/' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource