diff --git a/src/socket/verifyClient.js b/src/socket/verifyClient.js index 3405c87..49f38ff 100644 --- a/src/socket/verifyClient.js +++ b/src/socket/verifyClient.js @@ -21,7 +21,7 @@ function authenticateClient(req) { return new Promise( ((resolve) => { router(req, {}, async () => { - const country = req.headers['cf-ipcountry']; + const country = req.headers['cf-ipcountry'] || 'xx'; const user = (req.user) ? req.user : new User(null, getIPFromRequest(req)); user.country = country.toLowerCase(); diff --git a/src/utils/location.js b/src/utils/location.js index 4964957..47ca344 100644 --- a/src/utils/location.js +++ b/src/utils/location.js @@ -12,6 +12,9 @@ import ccCoords from '../data/countrycode-coords-array.json'; * @return coords X/Y coordinates of the country on the canvas */ export function ccToCoords(cc: string) { + if (!cc) { + return [0, 0]; + } const country = cc.toLowerCase(); const coords = ccCoords[country]; return (coords) || [0, 0];