From 5d1302585ab94be00acc72e842fb15c152220335 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Tue, 20 Jan 2026 00:18:18 +0000 Subject: [PATCH] feat: update next.config.js to handle GitHub Pages and improve basePath configuration --- next.config.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index a788b26..9d477ea 100644 --- a/next.config.js +++ b/next.config.js @@ -1,8 +1,15 @@ /* eslint-env node */ /** @type {import('next').NextConfig} */ +const isGithubPages = process.env.GITHUB_PAGES === 'true' || process.env.GITHUB_ACTIONS === 'true' +const repoBasePath = process.env.NEXT_PUBLIC_BASE_PATH + || (isGithubPages && process.env.GITHUB_REPOSITORY + ? `/${process.env.GITHUB_REPOSITORY.split('/')[1]}` + : '') + const nextConfig = { - output: process.env.BUILD_STATIC ? 'export' : 'standalone', - basePath: process.env.NEXT_PUBLIC_BASE_PATH || '', + output: process.env.BUILD_STATIC || isGithubPages ? 'export' : 'standalone', + basePath: repoBasePath, + assetPrefix: repoBasePath || undefined, images: { unoptimized: true, },