Skip to content

fix: render course pages dynamically to avoid production 500#260

Merged
rootulp merged 2 commits into
mainfrom
fix-course-dynamic-rendering
Jul 16, 2026
Merged

fix: render course pages dynamically to avoid production 500#260
rootulp merged 2 commits into
mainfrom
fix-course-dynamic-rendering

Conversation

@rootulp

@rootulp rootulp commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Motivation

Every /courses/[course] page (added in #259) returned a 500 in production — e.g. https://www.tritimes.org/courses/im703-melbourne.

Root cause

The page reads searchParams (?year=) but declared the static-generation config (generateStaticParams + revalidate = false) copied from /race/[slug]. Touching searchParams in a statically-generated route throws DYNAMIC_SERVER_USAGE at request time, 500ing the page. Dev masked it (dev always renders dynamically); only the production build (which classified the route ● SSG) failed. /race/[slug] is unaffected because it never reads searchParams.

Fix

Opt the route into dynamic rendering (export const dynamic = "force-dynamic") instead of static generation, since it must be request-time to read ?year=. The route now builds as ƒ (Dynamic).

Testing

Reproduced and verified in production mode (npm run build && npm start), which is what CI/dev missed:

  • Before: all /courses/[course] → 500 (DYNAMIC_SERVER_USAGE).
  • After: melbourne/swansea combined → 200, ?year=2023 → 200, nonexistent course/year → 404, zero server-render errors.

Note: CI runs npm run build (which succeeds even with the bug, since the error is request-time) but not a production-mode smoke test, so neither CI nor the dev-mode Playwright e2e caught this. Documented the invariant in a code comment to prevent reverting to the static config.

🤖 Generated with Claude Code

The course page reads searchParams (?year=) but declared the static-
generation config (generateStaticParams + revalidate=false) copied from
/race/[slug]. Touching searchParams in a statically-generated route throws
DYNAMIC_SERVER_USAGE at request time, 500ing every /courses/[course] page in
production (dev masked it — dev always renders dynamically). Opt into dynamic
rendering instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LFeozH85YsXjHHbE79Jqs3
@rootulp rootulp self-assigned this Jul 16, 2026
@rootulp
rootulp enabled auto-merge (squash) July 16, 2026 22:33
The PR-open push did not create a Vercel deployment (likely a dropped
webhook during a GitHub 503 window), so the required Vercel status never
posted and the PR stayed blocked. Empty commit to re-fire the deployment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LFeozH85YsXjHHbE79Jqs3
@rootulp
rootulp disabled auto-merge July 16, 2026 23:00
@rootulp
rootulp enabled auto-merge (squash) July 16, 2026 23:00
@rootulp
rootulp disabled auto-merge July 16, 2026 23:01
@rootulp
rootulp enabled auto-merge (squash) July 16, 2026 23:01
@rootulp
rootulp disabled auto-merge July 16, 2026 23:02
@rootulp
rootulp merged commit 26b8f26 into main Jul 16, 2026
5 checks passed
@rootulp
rootulp deleted the fix-course-dynamic-rendering branch July 16, 2026 23:02
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.

1 participant