From 7aad9f59364365bc09e6aee0cb379f6f962d9155 Mon Sep 17 00:00:00 2001 From: leej3 Date: Wed, 13 Nov 2024 14:44:30 +0000 Subject: [PATCH] fix api routing do not alter routes in the app itself Use traefik to strip the api prefix from the requests redirected to the api --- .github/workflows/deploy-opentofu.yml | 2 +- web/api/main.py | 1 - web/deploy/docker-compose.yaml | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-opentofu.yml b/.github/workflows/deploy-opentofu.yml index 59ec639..c104295 100644 --- a/.github/workflows/deploy-opentofu.yml +++ b/.github/workflows/deploy-opentofu.yml @@ -17,7 +17,7 @@ on: type: choice options: - staging - - production + - production pull_request: branches: - main diff --git a/web/api/main.py b/web/api/main.py index 28d32bc..fa9ad36 100644 --- a/web/api/main.py +++ b/web/api/main.py @@ -110,7 +110,6 @@ async def get_invocation_by_id(id: ObjectId): app=app, host="0.0.0.0", port=80, - root_path="/api", loop=loop, log_config=LOGGING_CONFIG, ) diff --git a/web/deploy/docker-compose.yaml b/web/deploy/docker-compose.yaml index ef55cc0..9c8fae0 100644 --- a/web/deploy/docker-compose.yaml +++ b/web/deploy/docker-compose.yaml @@ -12,6 +12,8 @@ services: - traefik.enable=true - traefik.docker.network=osm_traefik-public - traefik.http.routers.osm_web_api.rule=Host(`${DEPLOYMENT_URI}`) && PathPrefix(`/api`) + - "traefik.http.middlewares.strip-api-prefix.stripprefix.prefixes=/api" + - "traefik.http.routers.osm_web_api.middlewares=strip-api-prefix@docker" - "traefik.http.routers.osm_web_api.entrypoints=web,websecure" - "traefik.http.routers.osm_web_api.service=osm_web_api" - traefik.http.services.osm_web_api.loadbalancer.server.port=80