Skip to content

Commit

Permalink
fix: add conditional root path
Browse files Browse the repository at this point in the history
  • Loading branch information
rorre committed Jun 19, 2024
1 parent 52c5815 commit 9353875
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
gcloud auth configure-docker ${{ vars.REGION }}-docker.pkg.dev --quiet
docker container rm -f chefies-backend
docker image rm -f ${{ vars.GAR_LOCATION }}/backend
docker run --name chefies-backend -e GOOGLE_APPLICATION_CREDENTIALS="/app/keys/credentials.json" -d --restart always -p 9000:80 ${{ vars.GAR_LOCATION }}/backend
docker run --name chefies-backend -e PRODUCTION=1 -e GOOGLE_APPLICATION_CREDENTIALS="/app/keys/credentials.json" -d --restart always -p 9000:80 ${{ vars.GAR_LOCATION }}/backend
7 changes: 6 additions & 1 deletion cefies/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from fastapi import FastAPI
from dotenv import load_dotenv

Expand All @@ -6,7 +7,11 @@
import cefies.internal.firestore # noqa: F401 -- Intended to initialize Firebase
from cefies.routes import index_router, auth_router, profile_router

app = FastAPI(root_path="/api")
root_path = ""
if os.getenv("PRODUCTION"):
root_path = "/api"

app = FastAPI(root_path=root_path)
app.include_router(index_router)
app.include_router(auth_router)
app.include_router(profile_router)
6 changes: 5 additions & 1 deletion cefies/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 30

security = OAuth2PasswordBearer("/auth/login")
login_path = "/auth/login"
if os.getenv("PRODUCTION"):
login_path = "/api" + login_path

security = OAuth2PasswordBearer(login_path)


def authenticate_user(email: str, password: str):
Expand Down

0 comments on commit 9353875

Please sign in to comment.