File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4949
5050 - name : Build Next.js app
5151 run : pnpm run build
52+ env :
53+ # Set to empty string for custom domain (e.g., rektsafe.com)
54+ # Remove or comment out this line if using username.github.io/repo-name
55+ BASE_PATH : " "
5256
5357 - name : Upload artifact
5458 uses : actions/upload-pages-artifact@v3
Original file line number Diff line number Diff line change 11import type { NextConfig } from "next" ;
22
33// For GitHub Pages deployment:
4- // If using a custom domain, set basePath: ""
5- // If using username.github.io/repo-name, set basePath: "/repo-name"
4+ // If using a custom domain, set BASE_PATH="" or leave empty
5+ // If using username.github.io/repo-name, BASE_PATH defaults to "/repo-name"
66const isGithubActions = process . env . GITHUB_ACTIONS === "true" ;
77const repoName = process . env . GITHUB_REPOSITORY ?. split ( "/" ) [ 1 ] || "" ;
88
9+ // Allow manual override via BASE_PATH env var
10+ // For custom domain (e.g., rektsafe.com): set BASE_PATH=""
11+ // For project page (e.g., user.github.io/repo): leave unset or set BASE_PATH="/repo"
12+ const basePath =
13+ process . env . BASE_PATH !== undefined
14+ ? process . env . BASE_PATH
15+ : isGithubActions && repoName
16+ ? `/${ repoName } `
17+ : "" ;
18+
919const nextConfig : NextConfig = {
1020 output : "export" ,
1121 distDir : "dist" ,
12- basePath : isGithubActions && repoName ? `/ ${ repoName } ` : "" ,
13- assetPrefix : isGithubActions && repoName ? `/ ${ repoName } ` : "" ,
22+ basePath : basePath ,
23+ assetPrefix : basePath ,
1424 images : {
1525 unoptimized : true ,
1626 } ,
You can’t perform that action at this time.
0 commit comments