Skip to content

Commit bfaf29d

Browse files
committed
chore: attempt to fix the basePath in preview deployments
1 parent b834611 commit bfaf29d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@ jobs:
3838
run: npm run test
3939

4040
- name: Build application
41-
run: npm run build
41+
run: |
42+
echo "Building for branch: ${{ github.ref_name }}"
43+
echo "NODE_ENV: $NODE_ENV"
44+
echo "SURGE_PREVIEW: $SURGE_PREVIEW"
45+
npm run build
4246
env:
4347
NEXT_PUBLIC_GA_ID: ${{ secrets.NEXT_PUBLIC_GA_ID }}
4448
NEXT_PUBLIC_REQUIRE_CONSENT: true
4549
NEXT_PUBLIC_ANONYMIZE_IP: true
50+
# Set SURGE_PREVIEW for non-master branches to disable basePath
51+
SURGE_PREVIEW: ${{ github.ref != 'refs/heads/master' && 'true' || '' }}
4652

4753
- name: Upload Pages Artifact (Production)
4854
if: github.ref == 'refs/heads/master'

next.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ const nextConfig: NextConfig = {
44
// Output as static site for GitHub Pages
55
output: 'export',
66

7-
// Base path for GitHub Pages (only in production)
8-
basePath: process.env.NODE_ENV === 'production' ? '/github-profile-readme-generator' : '',
7+
// Base path for GitHub Pages (only in production AND not for Surge previews)
8+
basePath:
9+
process.env.NODE_ENV === 'production' && !process.env.SURGE_PREVIEW
10+
? '/github-profile-readme-generator'
11+
: '',
912

1013
// Image optimization for static export
1114
images: {

0 commit comments

Comments
 (0)