Skip to content

Commit 4359e50

Browse files
committed
README updated to include ENVIRONMENT .env variable
1 parent 6e76f26 commit 4359e50

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
- [ ] Add mongoDB support
6666

6767
#### Security
68-
- [ ] FastAPI docs behind authentication and hidden based on the environment
68+
- [x] FastAPI docs behind authentication and hidden based on the environment
6969

7070
#### Structure
7171
- [ ] Remove python-decouple in favor of starlette.config
@@ -206,6 +206,16 @@ TEST_USERNAME="testeruser"
206206
TEST_PASSWORD="Str1ng$t"
207207
```
208208

209+
And Finally the environment:
210+
```
211+
# ------------- environment -------------
212+
ENVIRONMENT="local"
213+
```
214+
`ENVIRONMENT` can be one of `local`, `staging` and `production`, defaults to local, and changes the behavior of api `docs` endpoints:
215+
- **local:** `/docs`, `/redoc` and `/openapi.json` available
216+
- **staging:** `/docs`, `/redoc` and `/openapi.json` available for superusers
217+
- **production:** `/docs`, `/redoc` and `/openapi.json` not available
218+
209219
### 3.2 Docker Compose (preferred)
210220
To do it using docker compose, ensure you have docker and docker compose installed, then:
211221
While in the base project directory (FastAPI-boilerplate here), run:
@@ -763,6 +773,9 @@ Should be changed to:
763773
command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
764774
```
765775

776+
> **Warning**
777+
> Do not forget to set the `ENVIRONMENT` in `.env` to `production` unless you want the API docs to be public.
778+
766779
More on running it in production later.
767780

768781
## 7. Testing

0 commit comments

Comments
 (0)