mirror of
https://github.com/tiennm99/loldle.git
synced 2026-10-11 03:13:42 +00:00
fix: make basePath configurable via NEXT_PUBLIC_BASE_PATH env var
Enables platform-agnostic deployment — GitHub Pages sets the env var in CI, while Vercel/Netlify/local dev default to root path.
This commit is contained in:
1 parent
dc7603459f
commit
a130dd191b
3 files changed
+5
-2
No files matched your search
Vendored
+2
@@ -28,6 +28,8 @@ jobs:
|
|||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
env:
|
||||||
|
NEXT_PUBLIC_BASE_PATH: /loldle
|
||||||
|
|
||||||
- uses: actions/upload-pages-artifact@v3
|
- uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ export async function loadChampions() {
|
|||||||
if (loadPromise) return loadPromise;
|
if (loadPromise) return loadPromise;
|
||||||
|
|
||||||
loadPromise = (async () => {
|
loadPromise = (async () => {
|
||||||
const response = await fetch(`/loldle/champions.json`);
|
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||||
|
const response = await fetch(`${basePath}/champions.json`);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
loadPromise = null;
|
loadPromise = null;
|
||||||
throw new Error(`Failed to load champions: ${response.status}`);
|
throw new Error(`Failed to load champions: ${response.status}`);
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "export",
|
output: "export",
|
||||||
basePath: "/loldle",
|
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "",
|
||||||
images: {
|
images: {
|
||||||
unoptimized: true,
|
unoptimized: true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user