Skip to content

Latest commit

 

History

History
109 lines (79 loc) · 2.03 KB

File metadata and controls

109 lines (79 loc) · 2.03 KB

Local Preview Guide

How to Preview Your Built Site Locally

Since the site is configured with basePath: '/advisor-calculator' for GitHub Pages, you need to handle this for local preview.


Option 1: Use Python HTTP Server (Simplest)

This serves the files and lets you access at the correct path:

# From the project root
cd out
python3 -m http.server 8000

Then open in your browser:

http://localhost:8000/en.html

Or directly access any language:

To stop: Press Ctrl+C in the terminal


Option 2: Use npx serve with Base Path Simulation

# Serve with simulated subdirectory structure
npx serve out

Then open:

http://localhost:3000/en.html

Option 3: Temporarily Remove basePath for Testing

If you want to test at root path (http://localhost:3000/):

1. Edit next.config.js:

const nextConfig = {
  output: 'export',
  // basePath: '/advisor-calculator', // Comment this out temporarily
  trailingSlash: false,
  images: {
    unoptimized: true,
  },
  // ...
};

2. Rebuild:

npm run build

3. Serve:

npx serve out

4. Open:

http://localhost:3000/

⚠️ IMPORTANT: Don't forget to uncomment basePath before deploying to GitHub Pages!


Quick Command Summary

Fastest way (recommended):

cd out
python3 -m http.server 8000

Then visit: http://localhost:8000/en.html


Why basePath is needed for GitHub Pages

GitHub Pages serves your site at:

https://username.github.io/repo-name/

The basePath: '/advisor-calculator' tells Next.js to generate all links/assets with this prefix, so:

  • CSS: /advisor-calculator/_next/static/...
  • JS: /advisor-calculator/_next/static/...
  • Links: /advisor-calculator/en.html

Without it, GitHub Pages would look for files at the root and get 404 errors.