Why do I get 503 on custom 404 page (user Gitlab page)?

Hello :wave:

Recently I wanted to add a custom 404 page for my user page (https://soykje.gitlab.io), but for an unknown reason I get 503 and redirected to authentification page (login/signup).

What could be the reason of that? Is it possible to get a functional custom 404 page on Gitlab user page?

Thx in advance :pray:

Hi, as per the gitlab docs, it looks possible: Exploring GitLab Pages | GitLab

Hi, thx for your message. If I understood well the doc, my custom 404 is correctly generated, as I end with a 404.html file at the root of my public folder… :thinking:

But as it still doesn’t work, there should be something I missed, in my project configuration or my .gitlab-ci.yml?

Just in case, here it is:

image: node:lts

cache:
  paths:
    - node_modules/

pages:
  before_script:
    # Clean 'public' directory
    - find public -mindepth 1 -maxdepth 1 -type d | xargs rm -rf
    - find public -type f -name "*.html" | xargs rm -rf
    # Install packages
    - npm install
  script:
    # Build application and move content to 'public' directory
    - npm run publish
    # We need a last cleanup as mv command doesn't allow us to merge directories
    - find public -mindepth 1 -maxdepth 1 -type d | xargs rm -rf
    # We need to move and rename 404 file to make it work properly
    - mv out/404/index.html out/404.html
    - rm -d out/404
    # We copy output inside expected 'public' directory
    - mv out/* public
  after_script:
    # Cleanup
    - rm -rf out
  artifacts:
    paths:
      - public
  only:
    - master

Doing this, I’m getting a public directory such as:
Capture d’écran du 2021-06-17 23-32-02

Any idea of what I could be missing? Btw you can check the issue here: https://soykje.gitlab.io/fr/blog/nextjs-dynamic-route-typecript/ (I made a typo on my pathname on purpose for this example)

Thanks in advance! :pray:

Apparently there is a known issue that could be related: Bug: 404 not working on Gitlab pages set to public, everyone (#322752) · Issues · GitLab.org / GitLab · GitLab :sob: