File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ cython_debug/
173173# Credentials
174174local.env
175175prod.env
176+ local.yaml
176177
177178# Etc
178179junit.xml
Original file line number Diff line number Diff line change 1717
1818.PHONY : local
1919local :
20- export DESCRIPTION=$$(cat README.md ) && source ./envs/local.env && uv run uvicorn app.main:app --host 0.0.0.0 --port $$ {PORT} --env-file ./envs/local.env --reload --log-level debug
20+ export DESCRIPTION=$$(cat README.md ) && source ./envs/local.env && uv run uvicorn app.main:app --host 0.0.0.0 --port $$ {PORT} --env-file ./envs/local.env --proxy-headers --forwarded-allow-ips= ' * ' --reload
2121
2222.PHONY : prod
2323prod :
24- export DESCRIPTION=$$(cat README.md ) && uv run uvicorn app.main:app --host 0.0.0.0 --env-file ./envs/prod.env
24+ export DESCRIPTION=$$(cat README.md ) && uv run uvicorn app.main:app --host 0.0.0.0 --env-file ./envs/prod.env --proxy-headers --forwarded-allow-ips= ' * '
Original file line number Diff line number Diff line change @@ -11,14 +11,22 @@ class LoggingMiddleware(BaseHTTPMiddleware):
1111 async def dispatch (
1212 self , request : Request , call_next : RequestResponseEndpoint
1313 ) -> Response :
14- if request .client :
15- ip = ansi_format (
16- f"{ request .client .host } :{ request .client .port } " ,
17- bg_color = ANSI_BG_COLOR .LIGHT_BLACK ,
18- style = [ANSI_STYLE .UNDERLINE , ANSI_STYLE .BOLD ],
19- )
14+ if request .headers .get ("x-real-ip" ):
15+ ip = request .headers .get ("x-real-ip" )
16+ logger .info (ip )
17+ elif request .headers .get ("x-forwarded-for" ):
18+ ip = request .headers .get ("x-forwarded-for" )
19+ logger .info (ip )
20+ elif request .client :
21+ ip = request .client .host
22+ logger .info (ip )
2023 else :
2124 ip = "None"
25+ ip = ansi_format (
26+ f"{ ip } " ,
27+ bg_color = ANSI_BG_COLOR .LIGHT_BLACK ,
28+ style = [ANSI_STYLE .UNDERLINE , ANSI_STYLE .BOLD ],
29+ )
2230 url = ansi_format (
2331 str (request .url ),
2432 bg_color = ANSI_BG_COLOR .LIGHT_BLACK ,
You can’t perform that action at this time.
0 commit comments