소스 검색

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();