Skip to content

fix: update CloudFront reverse proxy to use AllViewerExceptHostHeader#5614

Merged
thesandlord merged 2 commits into
mainfrom
devin/1779595313-fix-cloudfront-reverse-proxy
May 24, 2026
Merged

fix: update CloudFront reverse proxy to use AllViewerExceptHostHeader#5614
thesandlord merged 2 commits into
mainfrom
devin/1779595313-fix-cloudfront-reverse-proxy

Conversation

@thesandlord
Copy link
Copy Markdown
Contributor

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 AllViewer as the origin request policy, which forwards the viewer's Host header (e.g., fyno.io) to Vercel. Vercel uses Host for deployment routing and doesn't recognize the customer's domain, returning DEPLOYMENT_NOT_FOUND errors or RSC payloads instead of HTML.

Fix: Use AllViewerExceptHostHeader instead — this forwards all viewer headers except Host, letting CloudFront set it to app.buildwithfern.com (the origin domain) as required.

Changes:

  • Replace AllViewerAllViewerExceptHostHeader origin request policy
  • Add detailed origin configuration (TLS version, protocol, SSL settings)
  • Add a step to verify cache behavior ordering
  • Add an explicit warning against using AllViewer
  • Expand the caching warning with more detail
  • Add RSC content-type check to the verification section

Review & Testing Checklist for Human

  • Verify AllViewerExceptHostHeader is the correct AWS managed origin request policy name (it is — AWS docs)
  • Confirm the updated instructions render correctly on the preview site
  • Test with a real CloudFront distribution if possible — verify curl -sI https://yourdomain.com/docs returns content-type: text/html (not text/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

…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-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

| Setting | Value |
|---|---|
| **Path pattern** | `/docs*` |
| **Origin** | The Fern origin you just created |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 [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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚫 [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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 [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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'TTL' has no definition.

@thesandlord thesandlord merged commit 1a370ed into main May 24, 2026
3 checks passed
@thesandlord thesandlord deleted the devin/1779595313-fix-cloudfront-reverse-proxy branch May 24, 2026 04:05

<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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 [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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'TTL' has no definition.

@github-actions
Copy link
Copy Markdown
Contributor

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