Skip to content

fix: full port of cloud SSR/navigation — exact match#430

Merged
jesposito merged 7 commits intomainfrom
fix/sitenav-complete-cloud-port
Mar 30, 2026
Merged

fix: full port of cloud SSR/navigation — exact match#430
jesposito merged 7 commits intomainfrom
fix/sitenav-complete-cloud-port

Conversation

@jesposito
Copy link
Copy Markdown
Owner

Summary

Direct copy of ALL SSR and navigation files from the cloud repo (facets-sh) which has zero rapid-click issues:

  • +page.server.ts — cloud version with X-Internal, proper error handling, siteNav via parent()
  • [slug]/+page.server.ts — cloud version with X-Internal, siteNavEnabled
  • +layout.server.ts — cloud version with appUrl, debug logging
  • +layout.svelte — cloud version with initPlan fallback, proper store init
  • slug.ts — cloud version of param matcher

Build verified clean. Only remaining differences from cloud: stone→gray palette, no courses feature.

🤖 Generated with Claude Code

Direct copy of all SSR and navigation files from facets-sh cloud.
Only difference: no courses link, no hasFeature import.
Build verified clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jesposito jesposito force-pushed the fix/sitenav-complete-cloud-port branch from fecbe41 to 4b08ba0 Compare March 30, 2026 01:51
Jed Esposito and others added 6 commits March 30, 2026 15:00
The <html class="%sveltekit.theme%"> placeholder was removed from
SvelteKit and renders as literal text in production. This causes a
hydration mismatch on every page load, which corrupts SvelteKit's
client router during rapid SPA navigation — leading to 404 flashes
and WelcomePage appearing incorrectly.

Also adds dark mode FOUC prevention script from cloud version.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cloudflare's Email Address Obfuscation rewrites email addresses in
SSR HTML, causing a Svelte hydration mismatch (server HTML ≠ client
DOM). This corrupts SvelteKit's client router, causing 404 flashes
and WelcomePage on rapid SPA navigation.

Fix: wrap ATS content emails with <!--email_off--> comments, which
Cloudflare respects and skips.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Self-hosted Caddyfile was missing critical headers that cloud has:
- Cache-Control "no-store, no-cache" on /api/* (prevents stale cached responses)
- Cache-Control "immutable" on /_app/immutable/* (proper asset caching)
- Cache-Control on /api/files/* (uploaded content caching)
- CSP header (XSS protection)
- HSTS header
- Request body size limit (25MB)
- X-Internal header stripping (prevents spoofing)
- Maintenance mode support

Missing cache-control on API routes likely caused Cloudflare or browser
to cache __data.json responses, returning stale data during rapid SPA
navigation → 404 error page.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…acet versions

The +page.svelte files had 179 lines of differences from cloud despite
earlier claims of being "identical." Copied the actual cloud files
including CoursesSection and NewsletterSection components.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CSS '* {' inside the heredoc HTML was interpreted by Caddy as a
block opener, causing parse failure on line 59.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Root cause of rapid-click 404s and WelcomePage: SSR fetches to
/api/homepage were getting 429 Too Many Requests from PocketBase's
rate limiter. The X-Internal header was only bypassing analytics
tracking, not rate limiting.

Server logs showed: [ROOT PAGE] Homepage API error: 429 {"error":"too many requests"}

This caused the homepage server load to return profile:null,
which the template correctly interpreted as "first time setup."

Fix: skip rate limiting entirely when X-Internal: true is present.
Caddy strips this header from external requests, so only same-container
SSR fetches can use it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jesposito jesposito merged commit 47da525 into main Mar 30, 2026
13 checks passed
@jesposito jesposito deleted the fix/sitenav-complete-cloud-port branch April 1, 2026 23:53
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