-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] Make root_path
for app configurable
#400
Conversation
Reviewer's Guide by SourceryThis pull request introduces a configurable root path for the FastAPI app using the environment variable Sequence diagram for request handling with configurable root pathsequenceDiagram
participant Client
participant NGINX
participant FastAPI
Note over Client,FastAPI: Example with root_path=/api
Client->>NGINX: GET /api/docs
NGINX->>FastAPI: GET /docs
Note over NGINX,FastAPI: NGINX strips /api prefix
FastAPI-->>NGINX: HTML response with /api/openapi.json
NGINX-->>Client: HTML response
Client->>NGINX: GET /api/openapi.json
NGINX->>FastAPI: GET /openapi.json
FastAPI-->>NGINX: OpenAPI JSON
NGINX-->>Client: OpenAPI JSON
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
root_path
for app configurableroot_path
for app configurable
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #400 +/- ##
==========================================
+ Coverage 96.95% 97.10% +0.15%
==========================================
Files 24 24
Lines 820 830 +10
==========================================
+ Hits 795 806 +11
+ Misses 25 24 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alyssadai for addressing this. The code changes and default updates make sense to me!
My main comment is that the test you added is currently a bit hard to follow. Take a look and add a docstring to clarify.
then 🧑🍳
Closes Support subdirectory root paths when API is behind a proxy #392
Closes Replace old default values for ENV variables #356
Related to: Add and document env vars for API root paths recipes#102
Changes proposed in this pull request:
NB_NAPI_ROOT_PATH
To test the behaviour locally using NGINX, I followed these steps:
sudo apt update && sudo apt install nginx
/etc/nginx/sites-available/fastapi_test
:NB_NAPI_ROOT_PATH=/api
and launch FastAPI app locallyChecklist
This section is for the PR reviewer
[ENH]
,[FIX]
,[REF]
,[TST]
,[CI]
,[MNT]
,[INF]
,[MODEL]
,[DOC]
) (see our Contributing Guidelines for more info)skip-release
(to be applied by maintainers only)Closes #XXXX
For new features:
For bug fixes:
Summary by Sourcery
Make the root path for the app configurable via the NB_NAPI_ROOT_PATH environment variable. Update the documentation links to reflect the configured root path.
Enhancements:
Tests: