@@ -157,7 +157,7 @@ def host(self) -> str:
157157 property can safely return the host without any validation.
158158 """
159159 # We try three options, in order of decreasing preference.
160- if settings .USE_X_FORWARDED_HOST and ("HTTP_X_FORWARDED_HOST" in self .meta ):
160+ if settings .HTTP_X_FORWARDED_HOST and ("HTTP_X_FORWARDED_HOST" in self .meta ):
161161 host = self .meta ["HTTP_X_FORWARDED_HOST" ]
162162 elif "HTTP_HOST" in self .meta :
163163 host = self .meta ["HTTP_HOST" ]
@@ -172,7 +172,7 @@ def host(self) -> str:
172172 @cached_property
173173 def port (self ) -> str :
174174 """Return the port number for the request as a string."""
175- if settings .USE_X_FORWARDED_PORT and "HTTP_X_FORWARDED_PORT" in self .meta :
175+ if settings .HTTP_X_FORWARDED_PORT and "HTTP_X_FORWARDED_PORT" in self .meta :
176176 port = self .meta ["HTTP_X_FORWARDED_PORT" ]
177177 else :
178178 port = self .meta ["SERVER_PORT" ]
@@ -182,13 +182,13 @@ def port(self) -> str:
182182 def client_ip (self ) -> str :
183183 """Return the client's IP address.
184184
185- If USE_X_FORWARDED_FOR is True, checks the X-Forwarded-For header first
185+ If HTTP_X_FORWARDED_FOR is True, checks the X-Forwarded-For header first
186186 (using the first/leftmost IP). Otherwise returns REMOTE_ADDR directly.
187187
188- Only enable USE_X_FORWARDED_FOR when behind a trusted proxy that
188+ Only enable HTTP_X_FORWARDED_FOR when behind a trusted proxy that
189189 overwrites the X-Forwarded-For header.
190190 """
191- if settings .USE_X_FORWARDED_FOR :
191+ if settings .HTTP_X_FORWARDED_FOR :
192192 if xff := self .headers .get ("X-Forwarded-For" ):
193193 return xff .split ("," )[0 ].strip ()
194194 return self .meta ["REMOTE_ADDR" ]
0 commit comments