瀏覽代碼

fix: 修复登录时获取不到客户端真实ip

lanjianrong 4 年之前
父節點
當前提交
74262ecc75
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      app/service/login_logging.js

+ 1 - 1
app/service/login_logging.js

@@ -37,7 +37,7 @@ module.exports = app => {
          */
         async addLoginLog() {
             const { ctx } = this;
-            const ip = ctx.header['x-real-ip'] ? ctx.header['x-real-ip'] : '';
+            const ip = ctx.request.ip ? ctx.request.ip : '';
             const ipInfo = await this.getIpInfoFromApi(ip);
             const parser = new UAParser(ctx.header['user-agent']);
             const osInfo = parser.getOS();