fix: full port of cloud SSR/navigation — exact match#430
Merged
Conversation
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>
fecbe41 to
4b08ba0
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 initslug.ts— cloud version of param matcherBuild verified clean. Only remaining differences from cloud: stone→gray palette, no courses feature.
🤖 Generated with Claude Code