Error 502 when browsing HTML artifacts

Hello,
I’m trying to implement TDD to my project by writing unit tests and then execute it using Gitlab CI. I use coverage library to generate the HTML artifacts which then would be browsable. The tests passed and all the files are created, but when I tried to open the HTML file it shows

502 Bad Gateway - nginx

. It has no problem when I download and open them locally. My configuration:

image: python:3.11
stages:         
  - test

unit-test-job:   
  stage: test    
  script:
    - python -m pip install pytest coverage
    - coverage run -m pytest $CI_PROJECT_DIR/unit_tests/
    - coverage html
  artifacts:
    paths:
      - htmlcov
    expire_in: 30 days

before_script:
  - python3 -m pip install numpy pandas

pages:
  script:
    - python3 -m pip install sphinx tomli furo myst-parser
    - sphinx-build -b html docs/source public
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_BRANCH == "docs"

I thought it may be because I have my Gitlab Pages set up, but I’m not so sure. I’ve checked this issue but again I’m not so sure if it fits my situation. (I’m using company’s self-hosted gitlab through the browser, if that helps).

Thank you! I’m really new in this so any pointer would be appreciated, also please let me know if this isn’t the correct approach.