More fixes for geoip stuff.
This commit is contained in:
parent
79ea3258f1
commit
b8da7f547f
1 changed files with 1 additions and 1 deletions
|
@ -84,7 +84,7 @@ setupChinaRedirectMiddleware = (app) ->
|
||||||
speaksChinese = firstLanguage and firstLanguage.indexOf('zh') isnt -1
|
speaksChinese = firstLanguage and firstLanguage.indexOf('zh') isnt -1
|
||||||
unless config.tokyo
|
unless config.tokyo
|
||||||
ip = req.headers['x-forwarded-for'] or req.connection.remoteAddress
|
ip = req.headers['x-forwarded-for'] or req.connection.remoteAddress
|
||||||
ip = ip?.split(' ')[0] # If there are two IP addresses, say because of CloudFlare, we just take the first.
|
ip = ip?.split(/,? /)[0] # If there are two IP addresses, say because of CloudFlare, we just take the first.
|
||||||
geo = geoip.lookup(ip)
|
geo = geoip.lookup(ip)
|
||||||
if speaksChinese or geo?.country is "CN"
|
if speaksChinese or geo?.country is "CN"
|
||||||
log.info("Should we redirect to Tokyo server? speaksChinese: #{speaksChinese}, firstLanguage: #{firstLanguage}, ip: #{ip}, geo: #{geo} -- so redirecting? #{geo?.country is 'CN' and speaksChinese}")
|
log.info("Should we redirect to Tokyo server? speaksChinese: #{speaksChinese}, firstLanguage: #{firstLanguage}, ip: #{ip}, geo: #{geo} -- so redirecting? #{geo?.country is 'CN' and speaksChinese}")
|
||||||
|
|
Reference in a new issue