Skip to content

fix(docs): expose NEXT_PUBLIC_BASE_PATH so blueprint sample fetch works on GitHub Pages#218

Merged
solidsnakedev merged 1 commit intomainfrom
fix/blueprint-sample-base-path
Mar 20, 2026
Merged

fix(docs): expose NEXT_PUBLIC_BASE_PATH so blueprint sample fetch works on GitHub Pages#218
solidsnakedev merged 1 commit intomainfrom
fix/blueprint-sample-base-path

Conversation

@solidsnakedev
Copy link
Collaborator

Problem

The "Load Sample" button on the Blueprint Codegen tool was returning "Failed to load sample blueprint" on the GitHub Pages deployment.

loadSample() fetched ${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}/sample-blueprint.json, but NEXT_PUBLIC_BASE_PATH was never set, so it always resolved to /sample-blueprint.json — a 404 on GitHub Pages (where the site lives under /evolution-sdk/).

Fix

Extract basePath into a variable and expose it via env.NEXT_PUBLIC_BASE_PATH in next.config.mjs. Next.js bakes env.* values into the static export at build time, so the correct prefix (/evolution-sdk) is now available client-side.

History

  1. Originally: fetch('/sample-blueprint.json') — worked locally, broken on GH Pages
  2. Commit 2f2a6d5: hardcoded to /evolution-sdk/sample-blueprint.json — worked on GH Pages, broken locally
  3. Later refactored to use NEXT_PUBLIC_BASE_PATH — correct pattern, but the env var was never injected
  4. This PR: actually injects the env var

Copilot AI review requested due to automatic review settings March 20, 2026 16:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes GitHub Pages deployment of the Blueprint Codegen “Load Sample” flow by ensuring the client-side fetch uses the correct base path during static export.

Changes:

  • Introduce a shared basePath variable derived from GITHUB_ACTIONS.
  • Reuse basePath for both basePath and assetPrefix.
  • Expose NEXT_PUBLIC_BASE_PATH via next.config.mjs env so it’s baked into the static build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const withMDX = createMDX()

const isCI = !!process.env.GITHUB_ACTIONS
const basePath = isCI ? '/evolution-sdk' : ''
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding '/evolution-sdk' makes the docs build fragile for repo renames and forks (GitHub Pages base path is typically /${repoName}). Consider deriving the base path from CI metadata (e.g., process.env.GITHUB_REPOSITORY/${repoName}) and/or allowing an explicit override via an env var, then use that computed value for basePath, assetPrefix, and env.NEXT_PUBLIC_BASE_PATH.

Suggested change
const basePath = isCI ? '/evolution-sdk' : ''
const explicitBasePath = process.env.DOCS_BASE_PATH
const inferredBasePath = process.env.GITHUB_REPOSITORY
? `/${process.env.GITHUB_REPOSITORY.split('/').pop()}`
: ''
const basePath = explicitBasePath ?? (isCI ? inferredBasePath : '')

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +18
basePath,
assetPrefix: basePath,
env: {
NEXT_PUBLIC_BASE_PATH: basePath,
},
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding '/evolution-sdk' makes the docs build fragile for repo renames and forks (GitHub Pages base path is typically /${repoName}). Consider deriving the base path from CI metadata (e.g., process.env.GITHUB_REPOSITORY/${repoName}) and/or allowing an explicit override via an env var, then use that computed value for basePath, assetPrefix, and env.NEXT_PUBLIC_BASE_PATH.

Copilot uses AI. Check for mistakes.
@solidsnakedev solidsnakedev merged commit cb5b3f8 into main Mar 20, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants