Skip to content

Commit e1cced2

Browse files
committed
Attempt fixing image issue
1 parent 1aa7e0a commit e1cced2

File tree

2 files changed

+27
-30
lines changed

2 files changed

+27
-30
lines changed

.github/workflows/nextjs.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
1-
# Sample workflow for building and deploying a Next.js site to GitHub Pages
2-
#
3-
# To get started with Next.js see: https://nextjs.org/docs/getting-started
4-
#
51
name: Deploy Next.js site to Pages
62

73
on:
8-
# Runs on pushes targeting the default branch
94
push:
105
branches: ["main"]
11-
12-
# Allows you to run this workflow manually from the Actions tab
136
workflow_dispatch:
147

15-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
168
permissions:
179
contents: read
1810
pages: write
1911
id-token: write
2012

21-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2313
concurrency:
2414
group: "pages"
2515
cancel-in-progress: false
2616

2717
jobs:
28-
# Build job
2918
build:
3019
runs-on: ubuntu-latest
3120
steps:
@@ -56,31 +45,27 @@ jobs:
5645
- name: Setup Pages
5746
uses: actions/configure-pages@v5
5847
with:
59-
# Automatically inject basePath in your Next.js configuration file and disable
60-
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
61-
#
62-
# You may remove this line if you want to manage the configuration yourself.
6348
static_site_generator: next
6449
- name: Restore cache
6550
uses: actions/cache@v4
6651
with:
6752
path: |
6853
.next/cache
69-
# Generate a new cache whenever packages or source files change.
7054
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
71-
# If source files changed but packages didn't, rebuild from a prior cache.
7255
restore-keys: |
7356
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
7457
- name: Install dependencies
7558
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
7659
- name: Build with Next.js
60+
env:
61+
NEXT_PUBLIC_BASE_PATH: /${{ github.event.repository.name }}
62+
NODE_ENV: production
7763
run: ${{ steps.detect-package-manager.outputs.runner }} next build
7864
- name: Upload artifact
7965
uses: actions/upload-pages-artifact@v3
8066
with:
8167
path: ./out
8268

83-
# Deployment job
8469
deploy:
8570
environment:
8671
name: github-pages

next.config.mjs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
async rewrites() {
3+
output: 'export',
4+
basePath: process.env.NODE_ENV === 'production' ? process.env.NEXT_PUBLIC_BASE_PATH : '',
5+
images: {
6+
unoptimized: true,
7+
},
8+
assetPrefix: process.env.NODE_ENV === 'production' ? process.env.NEXT_PUBLIC_BASE_PATH : '',
9+
// Keep your existing configurations
10+
async rewrites() {
411
return [
5-
{
6-
source: '/api/:path*',
7-
destination: `http://${process.env.NEXT_PUBLIC_BACKEND_HOST || 'localhost'}:${process.env.NEXT_PUBLIC_BACKEND_PORT || '8000'}/:path*`, // Proxy to Backend
8-
},
12+
{
13+
source: '/api/:path*',
14+
destination: `http://${process.env.NEXT_PUBLIC_BACKEND_HOST || 'localhost'}:${process.env.NEXT_PUBLIC_BACKEND_PORT || '8000'}/:path*`,
15+
},
916
]
10-
},
11-
serverRuntimeConfig: {
17+
},
18+
serverRuntimeConfig: {
1219
backendHost: process.env.NEXT_PUBLIC_BACKEND_HOST || 'localhost',
1320
backendPort: process.env.NEXT_PUBLIC_BACKEND_PORT || '8000',
14-
},
15-
publicRuntimeConfig: {
21+
},
22+
publicRuntimeConfig: {
1623
backendHost: process.env.NEXT_PUBLIC_BACKEND_HOST || 'localhost',
1724
backendPort: process.env.NEXT_PUBLIC_BACKEND_PORT || '8000',
18-
},
19-
}
25+
},
26+
}
2027

21-
export default nextConfig
28+
// Handle rewrites differently for static export
29+
if (process.env.NODE_ENV === 'production') {
30+
delete nextConfig.rewrites;
31+
}
32+
33+
export default nextConfig

0 commit comments

Comments
 (0)