From c9cb780dc4287731a2465601aade6af8b3c57ffd Mon Sep 17 00:00:00 2001 From: Amine Saboni Date: Fri, 8 Nov 2024 13:33:49 +0100 Subject: [PATCH 1/2] feat: add CORS middleware --- backend/bloom/app.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/bloom/app.py b/backend/bloom/app.py index 5c522255..0df914a5 100644 --- a/backend/bloom/app.py +++ b/backend/bloom/app.py @@ -6,6 +6,7 @@ from bloom.routers.v1.vessels import router as router_vessels_v1 from bloom.routers.v1.ports import router as router_ports_v1 from bloom.routers.v1.zones import router as router_zones_v1 +from starlette.middleware.cors import CORSMiddleware from bloom.config import settings @@ -36,4 +37,16 @@ async def root_api_v1(request:Request): app.include_router(router_vessels_v1,prefix=API_PREFIX_V1,tags=["Vessels"]) app.include_router(router_zones_v1,prefix=API_PREFIX_V1,tags=["Zones"]) +origins = [ + "http://localhost", + "http://localhost:3000", + ] + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) From f7cfb683b99b1183bf74ad0aefb00fa73bc04c77 Mon Sep 17 00:00:00 2001 From: Amine Saboni Date: Fri, 8 Nov 2024 13:37:37 +0100 Subject: [PATCH 2/2] fix: remove poetry from tests management --- .github/workflows/pre-commit.yaml | 6 ------ tox.ini | 2 -- 2 files changed, 8 deletions(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 6ce1e157..eb9dbbc6 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -11,12 +11,6 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - - name: Install poetry - run: | - cd backend - python -m pip install poetry - poetry export --with dev --format=requirements.txt --output=requirements.txt - name: set PY run: echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV - uses: actions/cache@v1 diff --git a/tox.ini b/tox.ini index bceaca45..1c7f38fb 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,6 @@ env = py310 [testenv] deps = - poetry pytest recreate = @@ -12,7 +11,6 @@ recreate = changedir = ./backend commands = - poetry install --with dev # tests are failing due to test database missing on github # todo enable database for testing #python -m pytest -vv