SSG NextJS on Gitlab Pages stucked on 404?

Viewed 824

I started a simple SSG NextJS project to build my personal website/portfolio: https://gitlab.com/soykje/soykje.gitlab.io, that I want to deploy using Gitlab pages (but without the now stuff...).

I created the .gitlab-ci.yml and updated the next.config.js to take care of assetPrefix parameter, but still I'm getting a mysterious 404. And I can't find a way to fix it, as the CI/CD tells everything is fine... :(

Here is my .gitlab-ci.yml:

image: node

cache:
  paths:
    - node_modules

before_script:
  - npm install

pages:
  script:
    - npm run publish # eq. to "next build && next export"
    - mv out public
  artifacts:
    paths:
      - public
  only:
    - master

Did anyone encounter the same issue deploying a static NextJS project using Gitlab Pages? Any help would be great, thx in advance!

1 Answers

Ok I found the reason: I was not using the mv command properly... So finally I ended up with the following config, and everything runs fine:

image: node

before_script:
  - npm install

cache:
  paths:
    - node_modules

pages:
  script:
    - npm run publish
    - mv out/* public
    - rm -rf out
  artifacts:
    paths:
      - public
  only:
    - master

Hope that will help!

Related