diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6d764326ffd43bb5d6664bc11fbc1b2e016c1f7c..5ff395db1f38485fa84c53deba44a5d3d87e81a5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,6 +24,7 @@ test:
     - source $VIRTUAL_ENV/bin/activate
     - pip install -r requirements.txt
     - export PYTHONPATH=$PYTHONPATH:/home/gitlab-runner/builds/t3_38ooWt/0/mx/heidi-v2/backend
+    - cd /home/gitlab-runner/builds/t3_38ooWt/0/mx/heidi-v2  # Change to the project root
     - pytest --cov=app --cov-report=xml  # Run tests and generate coverage report
 
 lint:
diff --git a/backend/main.py b/backend/main.py
index 95766b20b7a758883f55d01efa095e8b41381170..430ce7751901c97e55c1f71aa600be8b743e8510 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -28,11 +28,12 @@ def get_project_metadata():
     from pathlib import Path
     import tomllib
 
-    # Adjust path resolution to pinpoint the actual folder containing `pyproject.toml`
-    root_dir = Path(__file__).resolve().parent.parent.parent  # Root of the repository
-    pyproject_path = root_dir / "pyproject.toml"  # Update properly
+    # Dynamically resolve the project root folder correctly.
+    # Assume that `pyproject.toml` is located in the heidi-v2 root folder
+    root_dir = Path(__file__).resolve().parent.parent.parent
+    pyproject_path = root_dir / "heidi-v2" / "pyproject.toml"
 
-    print(f"Looking for pyproject.toml at: {pyproject_path}")  # Debug output
+    print(f"Looking for pyproject.toml at: {pyproject_path}")  # Debugging output
 
     if not pyproject_path.exists():
         raise FileNotFoundError(f"{pyproject_path} not found")