Skip to content

Commit

Permalink
CORS changes for gettting IP
Browse files Browse the repository at this point in the history
  • Loading branch information
jolzee committed Apr 2, 2020
1 parent a66f06d commit 4f51ca1
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/utils/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,20 @@ export default class Setup {
LocalStorage.keyExists(STORAGE_KEY + "loc").then(exists => {
if (exists) {
LocalStorage.get(STORAGE_KEY + "loc").then(data => {
superagent.get("https://api.ipify.org").then(res => {
if (res.text === data.ip) {
logger.debug(
`📍 Found Location Info in LocalStorage. IP hasn't changed`,
data
);
this.LOCATION = data;
resolve(vuetify);
} else {
this.obtainLocation(resolve, vuetify);
}
});
superagent
.get("https://cors-anywhere.herokuapp.com/https://api.ipify.org")
.then(res => {
if (res.text === data.ip) {
logger.debug(
`📍 Found Location Info in LocalStorage. IP hasn't changed`,
data
);
this.LOCATION = data;
resolve(vuetify);
} else {
this.obtainLocation(resolve, vuetify);
}
});
});
} else {
this.obtainLocation(resolve, vuetify);
Expand All @@ -285,7 +287,7 @@ export default class Setup {
obtainLocation(resolve, vuetify) {
let browserIp;
superagent
.get("https://api.ipify.org")
.get("https://cors-anywhere.herokuapp.com/https://api.ipify.org")
.then(res => {
browserIp = res.text;
return superagent
Expand Down

0 comments on commit 4f51ca1

Please sign in to comment.