Skip to content

Commit

Permalink
#84 Bug: 환경 여부에 따라 IP 취득 헤더 수정
Browse files Browse the repository at this point in the history
Nginx conf에서 X-Real-IP로 remote_addr을 할당하였다.
  • Loading branch information
fnzksxl committed Aug 22, 2024
1 parent d22ba6b commit 25c66ef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wtnt/team/team/service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.cache import cache

import wtnt.settings as api_settings
import core.exception.team as team_exception
import core.exception.notfound as notfound_exception
from core.pagenations import TeamPagination
Expand Down Expand Up @@ -78,8 +79,12 @@ def get_team_detail(self):
cache_key = f"team_detail_{team_id}"

team = cache.get(cache_key)
if api_settings.DEBUG:
user_ip = self.request.META.get("REMOTE_ADDR")
else:
user_ip = self.request.META.get("HTTP_X_REAL_IP")

redis_ans = RedisUtils.sadd_view_client(team_id, user_id, self.request.META.get("REMOTE_ADDR"))
redis_ans = RedisUtils.sadd_view_client(team_id, user_id, user_ip)

if team is None:
team = self.get_team_data_from_id(team_id)
Expand Down

0 comments on commit 25c66ef

Please sign in to comment.