fix: update CloudFront reverse proxy to use AllViewerExceptHostHeader#5614
Conversation
…eptHostHeader - Replace AllViewer with AllViewerExceptHostHeader to prevent forwarding the viewer's Host header, which causes Fern's origin to return RSC payloads or deployment errors instead of HTML - Add detailed origin configuration (TLS, protocol, SSL settings) - Add step to verify behavior ordering - Add RSC content-type check to verification section - Expand caching warning with more detail Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| | Setting | Value | | ||
| |---|---| | ||
| | **Path pattern** | `/docs*` | | ||
| | **Origin** | The Fern origin you just created | |
There was a problem hiding this comment.
📝 [vale] reported by reviewdog 🐶
[FernStyles.Hedges] Avoid hedge words and filler like 'just'. Prefer direct statements.
| - **Cache policy**: `CachingDisabled` (AWS managed policy) | ||
| - **Origin request policy**: `AllViewer` (forwards all headers, query strings, and cookies) | ||
| <Warning> | ||
| Do not use the `AllViewer` origin request policy. It forwards the viewer's `Host` header (your domain) instead of the origin's, which causes Fern's origin to return errors or raw React Server Component payloads instead of HTML. |
There was a problem hiding this comment.
🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'don't' instead of 'Do not'.
|
|
||
| <Warning> | ||
| CloudFront ignores `CDN-Cache-Control` and `Surrogate-Control` — only the standard `Cache-Control` header is read. A custom cache policy with a non-zero default TTL caches responses regardless of Fern's `Cache-Control: max-age=0` directive. | ||
| CloudFront ignores `CDN-Cache-Control` and `Surrogate-Control` — only the standard `Cache-Control` header is read. If you use a custom cache policy instead of `CachingDisabled`, set the default, minimum, and maximum TTL to `0`. A non-zero default TTL caches HTML responses regardless of Fern's `Cache-Control: max-age=0` directive, which causes pages to break after Fern deploys an update. |
There was a problem hiding this comment.
📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'TTL' has no definition.
|
|
||
| <Warning> | ||
| CloudFront ignores `CDN-Cache-Control` and `Surrogate-Control` — only the standard `Cache-Control` header is read. A custom cache policy with a non-zero default TTL caches responses regardless of Fern's `Cache-Control: max-age=0` directive. | ||
| CloudFront ignores `CDN-Cache-Control` and `Surrogate-Control` — only the standard `Cache-Control` header is read. If you use a custom cache policy instead of `CachingDisabled`, set the default, minimum, and maximum TTL to `0`. A non-zero default TTL caches HTML responses regardless of Fern's `Cache-Control: max-age=0` directive, which causes pages to break after Fern deploys an update. |
There was a problem hiding this comment.
📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'TTL' has no definition.
|
|
||
| <Warning> | ||
| CloudFront ignores `CDN-Cache-Control` and `Surrogate-Control` — only the standard `Cache-Control` header is read. A custom cache policy with a non-zero default TTL caches responses regardless of Fern's `Cache-Control: max-age=0` directive. | ||
| CloudFront ignores `CDN-Cache-Control` and `Surrogate-Control` — only the standard `Cache-Control` header is read. If you use a custom cache policy instead of `CachingDisabled`, set the default, minimum, and maximum TTL to `0`. A non-zero default TTL caches HTML responses regardless of Fern's `Cache-Control: max-age=0` directive, which can cause stale content and errors. |
There was a problem hiding this comment.
📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'TTL' has no definition.
|
|
||
| <Warning> | ||
| CloudFront ignores `CDN-Cache-Control` and `Surrogate-Control` — only the standard `Cache-Control` header is read. A custom cache policy with a non-zero default TTL caches responses regardless of Fern's `Cache-Control: max-age=0` directive. | ||
| CloudFront ignores `CDN-Cache-Control` and `Surrogate-Control` — only the standard `Cache-Control` header is read. If you use a custom cache policy instead of `CachingDisabled`, set the default, minimum, and maximum TTL to `0`. A non-zero default TTL caches HTML responses regardless of Fern's `Cache-Control: max-age=0` directive, which can cause stale content and errors. |
There was a problem hiding this comment.
📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'TTL' has no definition.
|
🌿 Preview your docs: https://fern-preview-devin-1779595313-fix-cloudfront-reverse-proxy.docs.buildwithfern.com/learn Here are the markdown pages you've updated: |
Summary
Fixes the AWS CloudFront reverse proxy instructions to prevent Fern's origin from returning raw React Server Component (RSC) payloads instead of HTML.
Root cause: The previous instructions recommended
AllVieweras the origin request policy, which forwards the viewer'sHostheader (e.g.,fyno.io) to Vercel. Vercel usesHostfor deployment routing and doesn't recognize the customer's domain, returningDEPLOYMENT_NOT_FOUNDerrors or RSC payloads instead of HTML.Fix: Use
AllViewerExceptHostHeaderinstead — this forwards all viewer headers exceptHost, letting CloudFront set it toapp.buildwithfern.com(the origin domain) as required.Changes:
AllViewer→AllViewerExceptHostHeaderorigin request policyAllViewerReview & Testing Checklist for Human
AllViewerExceptHostHeaderis the correct AWS managed origin request policy name (it is — AWS docs)curl -sI https://yourdomain.com/docsreturnscontent-type: text/html(nottext/x-component)Notes
Triggered by a customer (fyno.io) experiencing raw RSC payloads from their CloudFront setup.
Link to Devin session: https://app.devin.ai/sessions/64d575f1063a466a8b81666eef178600
Requested by: @thesandlord