gaganpreet / fastapi-starter

A FastAPI based low code starter/boilerplate: SQLAlchemy 2.0 (async), Postgres, React-Admin, pytest and cypress
https://demo-project-fastapi-starter.fly.dev
MIT License
459 stars 49 forks source link

make BearerTransport URL respect settings.API_PATH #806

Open mischadiehm opened 7 months ago

mischadiehm commented 7 months ago

When changing the settings.API_PATH the BeaerTransport tokenUrl should also change. This way swagger auth works also seamless with the API_PATH change. Does this make sense to you?

diff --git a/{{cookiecutter.project_slug}}/backend/app/deps/users.py b/{{cookiecutter.project_slug}}/backend/app/deps/users.py
index bece38a..7dff0f7 100644
--- a/{{cookiecutter.project_slug}}/backend/app/deps/users.py
+++ b/{{cookiecutter.project_slug}}/backend/app/deps/users.py
@@ -15,7 +15,8 @@ from app.core.config import settings
 from app.deps.db import CurrentAsyncSession
 from app.models.user import User as UserModel

-bearer_transport = BearerTransport(tokenUrl="auth/jwt/login")
+bearer_transport = BearerTransport(tokenUrl=f"{settings.API_PATH}/auth/jwt/login")