chore: attempt to fix the basePath in preview deployments

This commit is contained in:
Rahul Jain
2025-10-14 10:53:05 +05:30
parent b834611004
commit bfaf29d3fc
2 changed files with 12 additions and 3 deletions
+7 -1
View File
@@ -38,11 +38,17 @@ jobs:
run: npm run test
- name: Build application
run: npm run build
run: |
echo "Building for branch: ${{ github.ref_name }}"
echo "NODE_ENV: $NODE_ENV"
echo "SURGE_PREVIEW: $SURGE_PREVIEW"
npm run build
env:
NEXT_PUBLIC_GA_ID: ${{ secrets.NEXT_PUBLIC_GA_ID }}
NEXT_PUBLIC_REQUIRE_CONSENT: true
NEXT_PUBLIC_ANONYMIZE_IP: true
# Set SURGE_PREVIEW for non-master branches to disable basePath
SURGE_PREVIEW: ${{ github.ref != 'refs/heads/master' && 'true' || '' }}
- name: Upload Pages Artifact (Production)
if: github.ref == 'refs/heads/master'
+5 -2
View File
@@ -4,8 +4,11 @@ const nextConfig: NextConfig = {
// Output as static site for GitHub Pages
output: 'export',
// Base path for GitHub Pages (only in production)
basePath: process.env.NODE_ENV === 'production' ? '/github-profile-readme-generator' : '',
// Base path for GitHub Pages (only in production AND not for Surge previews)
basePath:
process.env.NODE_ENV === 'production' && !process.env.SURGE_PREVIEW
? '/github-profile-readme-generator'
: '',
// Image optimization for static export
images: {