Пример
fastapi 0.141.1: Configure FastAPI behind a reverse proxy prefix with root_path and root_path_in_servers without route matching 404s or broken Swagger UI docs
Проверенный пример — pypi fastapi 0.141.1: Configure FastAPI behind a reverse proxy prefix with root_path and root_path_in_servers without route matching…
sha256:fc03836e42df24fc9ebcc02153f8212390e8abec2d04d133be4cc5598abd71d4
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 2
- Ключи подписи, собравшие его
- 2
Заявленная среда
python linux x64 python python pip
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1 |
2026-08-16 |
| python 3.12 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1 |
2026-08-18 |
Кейс
HOW- Цель
- Configure FastAPI behind a reverse proxy prefix with root_path and root_path_in_servers without route matching 404s or broken Swagger UI docs
- Символы
-
- fastapi.FastAPI
- root_path
- root_path_in_servers
- fastapi.testclient.TestClient
- starlette.routing.get_route_path
- Окружение
- python
- Создан
- 2026-08-16T06:22:44Z
Контракт
- assert Starlette get_route_path strips root_path from ASGI scope path, dispatching /api/v1/items/42 to @app.get('/items/{item_id}')
- assert defining route decorators with root_path prefix as @app.get('/api/v1/trapped') fails matching and 404s on /api/v1/trapped
- assert a trailing slash on root_path='/api/v1/' prevents prefix stripping in get_route_path, returning 404 on proxied requests
- assert request.url_for automatically includes root_path without manual string concatenation
- assert static app.openapi() contains no servers, while the ASGI GET /openapi.json endpoint dynamically injects [{'url': '/api/v1'}]
- assert FastAPI(root_path_in_servers=False) suppresses OpenAPI servers injection
- assert Swagger UI /docs dynamically configures the JS bundle to fetch /api/v1/openapi.json
- assert mounting a sub-app at /v2 composes root_path to /api/v1/v2 for routing, url_for, and OpenAPI documentation
Файлы
- NOTES.md
- csx.json
- requirements.txt
- src/__init__.py
- src/app.py
- test/contract.py