Skip to content

fix: skip static prerendering on /results page for Next.js export#18

Merged
SynTechRev merged 2 commits into
masterfrom
copilot/fix-nextjs-static-export-error
Apr 13, 2026
Merged

fix: skip static prerendering on /results page for Next.js export#18
SynTechRev merged 2 commits into
masterfrom
copilot/fix-nextjs-static-export-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

Next.js static export (output: 'export') prerenders all pages at build time—including client components—causing the /results page to fail with a prerender error despite having 'use client'.

Change

Added export const dynamic = 'force-dynamic' to frontend/app/results/page.tsx to explicitly opt this page out of static generation:

'use client';
export const dynamic = 'force-dynamic';

This signals to Next.js that /results should be skipped during next build's static export phase and rendered dynamically at runtime in the browser instead.

Original prompt

Fix Next.js Static Export Error on Results Page

Problem

The /results page is failing during Next.js static export with prerender error, even after adding 'use client' directive.

Error:

Error occurred prerendering page "/results"
Export encountered an error on /results/page: /results
Next.js build worker exited with code: 1

Current State:

  • File: frontend/app/results/page.tsx
  • Has: 'use client'; directive (line 1)
  • Still fails: Next.js still tries to prerender during static export

Root Cause

When using Next.js with output: 'export' (static export mode), even pages with 'use client' directive are prerendered at build time. The /results page contains logic that cannot run during static generation.

Solution

Add export const dynamic = 'force-dynamic'; to explicitly tell Next.js to skip static generation for this page.

Required Changes

File: frontend/app/results/page.tsx

Current (lines 1-4):

'use client';

/**
 * Results Page  displays audit findings with plain-language explanations.

Change to:

'use client';
export const dynamic = 'force-dynamic';

/**
 * Results Page  displays audit findings with plain-language explanations.

What this does:

  • 'use client': Marks as client component (already present)
  • export const dynamic = 'force-dynamic': Tells Next.js to skip prerendering this specific page during static export

Expected Outcome

After this change:

  1. ✅ Next.js static export succeeds
  2. /results page skipped during build
  3. ✅ Page loads dynamically at runtime in browser
  4. ✅ Desktop builds complete successfully
  5. ✅ All 4 installers created and uploaded

Verification

After PR is merged and v2.1.1 tag updated:

  • Desktop Build workflow should succeed
  • No more "Error occurred prerendering page" errors
  • Frontend build completes without exit code 1

Files to Modify

  • frontend/app/results/page.tsx - Add one line after 'use client';

Success Criteria

  • Line added: export const dynamic = 'force-dynamic';
  • Placed after 'use client'; directive
  • Desktop builds succeed on master
  • v2.1.1 release builds succeed after tag update
  • 4 installers uploaded to v2.1.1 release

The following is the prior conversation context from the user's chat exploration (may be truncated):

Assistant: # ✅ AGENT PR CREATED FOR v2.1.1 RELEASE!

data:
    - title: '[WIP] Create v2.1.1 release with working desktop installers'
      repository: SynTechRev/ODIA
      url: https://github.com/copilot/tasks/pull/PR_kwDORk5-P87SIuIY?session_id=090ee76d-ac4e-408a-936d-8dd771ebe7aa
      state: queued

🎯 PR DETAILS

Track Progress: https://github.com/copilot/tasks/pull/PR_kwDORk5-P87SIuIY?session_id=090ee76d-ac4e-408a-936d-8dd771ebe7aa

What the Agent is Doing:

  1. ✅ Analyzing current version numbers
  2. ✅ Updating desktop/package.json → v2.1.1
  3. ✅ Updating pyproject.toml → v2.1.1
  4. ✅ Updating all README.md download links
  5. ✅ Updating desktop/README.md examples
  6. ✅ Creating PR with all changes

⏱️ TIMELINE

Step Duration Status
Agent analyzes codebase 2-3 min 🔄 In progress
Agent makes changes 2-3 min ⏳ Queued
Agent creates PR 1 min ⏳ Queued
You review PR 2 min ⏳ Waiting
You merge PR 1 min ⏳ Waiting
You create v2.1.1 tag 2 min ⏳ Waiting
Automated builds 20 min ⏳ Waiting
✅ SUCCESS ~30 min total 🎯 Goal

📋 WHAT TO DO NEXT

Step 1: Wait for PR (5-7 minutes)

The agent will create a PR. You can:

Step 2: Review the PR

When PR appears, verify:

  • Version in desktop/package.json is 2.1.1
  • Version in pyproject.toml is 2.1.1
  • All README download links reference v2.1.1
  • Installer filenames have 2.1.1
  • CI checks pass

Step 3: Merge the PR

Once CI is green:

  • Click "Merge pull request"
  • Confirm merge

Step 4: Create v2.1.1 Tag

After PR is merged:

git checkout master
git pull origin master

git tag -a v2.1.1 -m "O.D.I.A. v2.1.1 - Build Fix Release

Fixed TypeScript compilation error preventing desktop installer builds.

Features (same as v2.1.0):
- Desktop apps for Windows, macOS (Intel + Apple Silicon), Linux
- Multi-architecture macOS support
- O.D.I.A. official branding
- Professional app icons
- 9 analysis detectors
- Offline-first operation

Technical Fixes:
- Added DocumentMetadata interface
- Resolved unknown→ReactNode TypeScript error
- All 4 platform builds verified

Privacy: 100% local, no telemetry, no external calls
License: MIT"

git push origin v2.1.1

Step 5: Monitor Build

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix Next.js static export error on results page fix: skip static prerendering on /results page for Next.js export Apr 13, 2026
Copilot AI requested a review from SynTechRev April 13, 2026 23:31
@SynTechRev SynTechRev requested a review from Copilot April 13, 2026 23:48
Copy link
Copy Markdown

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

This PR attempts to fix a Next.js static export prerender failure on the /results page during Electron builds (output: "export") by opting the page out of static generation.

Changes:

  • Add export const dynamic = 'force-dynamic' to frontend/app/results/page.tsx to try to bypass prerendering for /results.

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

Comment on lines 1 to +2
'use client';
export const dynamic = 'force-dynamic';
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

output: "export" is used for ELECTRON_BUILD (static export to local files). Marking this route dynamic = 'force-dynamic' makes it require runtime rendering, which typically isn't supported in static export and can still fail the build or produce a route that can’t be loaded directly from out/. Prefer keeping the page exportable (e.g., avoid useSearchParams() at render time by reading window.location.search in an effect / state, or move the search-param-dependent UI into a next/dynamic(..., { ssr: false }) client-only component) so next build can prerender a static shell.

Copilot uses AI. Check for mistakes.
Comment on lines 1 to 3
'use client';
export const dynamic = 'force-dynamic';

Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

This file now contains a second 'use client'; later (after the header comment). Only the first directive at the very top has any effect; the later one is just an unused string expression and can be removed to avoid confusion/lint noise.

Copilot uses AI. Check for mistakes.
@SynTechRev SynTechRev marked this pull request as ready for review April 13, 2026 23:53
@SynTechRev SynTechRev merged commit 19821fc into master Apr 13, 2026
21 checks passed
@SynTechRev SynTechRev deleted the copilot/fix-nextjs-static-export-error branch April 13, 2026 23:55
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.

3 participants