-
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
base: main
Are you sure you want to change the base?
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.11% +0.16%
==========================================
Files 24 24
Lines 820 831 +11
==========================================
+ Hits 795 807 +12
+ Misses 25 24 -1 ☔ View full report in Codecov by Sentry. |
Closes Support subdirectory root paths when API is behind a proxy #392
Closes Replace old default values for ENV variables #356
Todo: 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: