Skip to content

Commit 80eeef0

Browse files
committed
✨ Add --proxy-headers
1 parent 8970dd5 commit 80eeef0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/fastapi_cli/cli.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def _run(
5454
root_path: str = "",
5555
command: str,
5656
app: Union[str, None] = None,
57+
proxy_headers: bool = False,
5758
) -> None:
5859
try:
5960
use_uvicorn_app = get_import_string(path=path, app_name=app)
@@ -85,6 +86,7 @@ def _run(
8586
port=port,
8687
reload=reload,
8788
root_path=root_path,
89+
proxy_headers=proxy_headers,
8890
)
8991

9092

@@ -127,6 +129,12 @@ def dev(
127129
help="The name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically."
128130
),
129131
] = None,
132+
proxy_headers: Annotated[
133+
bool,
134+
typer.Option(
135+
help="Enable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info."
136+
),
137+
] = True,
130138
) -> Any:
131139
"""
132140
Run a [bold]FastAPI[/bold] app in [yellow]development[/yellow] mode. 🧪
@@ -161,6 +169,7 @@ def dev(
161169
root_path=root_path,
162170
app=app,
163171
command="dev",
172+
proxy_headers=proxy_headers,
164173
)
165174

166175

@@ -203,6 +212,12 @@ def run(
203212
help="The name of the variable that contains the [bold]FastAPI[/bold] app in the imported module or package. If not provided, it is detected automatically."
204213
),
205214
] = None,
215+
proxy_headers: Annotated[
216+
bool,
217+
typer.Option(
218+
help="Enable/Disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to populate remote address info."
219+
),
220+
] = True,
206221
) -> Any:
207222
"""
208223
Run a [bold]FastAPI[/bold] app in [green]production[/green] mode. 🚀
@@ -237,6 +252,7 @@ def run(
237252
root_path=root_path,
238253
app=app,
239254
command="run",
255+
proxy_headers=proxy_headers,
240256
)
241257

242258

0 commit comments

Comments
 (0)