fix(proxy): answer 404 for a veryfront domain that names no project - #3469
Conversation
`staging.veryfront.com` and `preview.veryfront.com` match the environment-root branch in `parseProjectDomain`: a veryfront domain with slug `null`. The handler returned a forwarding context for that state, so the request reached the runtime with `x-project-slug: ""` and came back 502 "Missing project context". That path could never succeed. The runtime has no project to serve and the header it needs cannot be filled in later, so every such request spent a round trip to report a configuration gap as an upstream failure. A custom domain in exactly this state already answers 404 "No project configured for domain", which is why `development.veryfront.com` — not in the environment-root list, so parsed as a custom domain — behaves correctly today while its two siblings do not. Answer the same way for both.
📝 WalkthroughWalkthroughThe proxy now returns a host-specific 404 for hosted Veryfront environment-root domains without a project slug. Local project-less hosts continue forwarding with ChangesProxy domain routing
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/proxy/handler.test.ts`:
- Around line 1626-1634: Add the production root and bare lvh.me, veryfront.me,
and veryfront.dev host forms to the host iteration in the project-less Veryfront
test, while preserving the existing request and 404 assertions for each host.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: c8d0e71d-6d99-4228-a98a-078af3f1b068
📒 Files selected for processing (2)
src/proxy/handler.test.tssrc/proxy/handler.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cdb270868
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The first version of this change returned 404 for every project-less veryfront domain, which broke local development: `ProjectsHandler` is enabled for exactly `isVeryfrontDomain && !projectSlug` and serves the project chooser at `/` and `/_projects`, so the forwarding path was not dead after all. A project-less host means two different things depending on where it is. Locally it means no project has been chosen yet and the chooser answers. Hosted it means the domain names no project at all and nothing can answer. `isHostedVeryfrontDomain` names that distinction so the 404 applies only to the hosted case. `isLocalDevHost` would have been the wrong predicate: it returns false for `staging.lvh.me`, which would have left that chooser broken.
Found while verifying the v0.1.1214 rollout.
Same condition, three hosts, two answers.
Why they differ.
parseProjectDomainhas an explicit environment-root branch for^(preview|staging|production)\.veryfront\.(com|org)$(src/server/utils/domain-parser.ts:168) that returns slugnullwithisVeryfrontDomain: true.developmentis not in that list, so it falls through to the custom-domain case and gets the correct 404. Its two siblings hithandler.ts:817, which returned a forwarding context;injectContextHeadersthen sendsx-project-slug: ""and the runtime answers 502.Why 404 is right for hosted domains. Nothing downstream can supply the missing slug, so each request spent a round trip to the renderer only to report a configuration gap as an upstream failure — and 502 reads as "the backend is broken", which is what made me stop and investigate mid-rollout. A custom domain in the same state has always answered 404.
Scope — corrected. My first version returned 404 for every project-less veryfront domain, including
lvh.me,veryfront.me,veryfront.devand the local environment roots. That was wrong, and the claim in the original description that those were intended scope was wrong too.ProjectsHandleris enabled for exactlyisVeryfrontDomain && !projectSlug(src/server/handlers/dev/projects/index.ts:44-58) and serves the project chooser at/and/_projects, so locally that state is meaningful, not broken. The forwarding path was not dead code. Thanks to @chatgpt-codex-connector for catching it.The 404 now applies only to hosted domains, via a new
isHostedVeryfrontDomainthat names the distinction: locally a project-less host means "no project chosen yet"; hosted it means the domain names no project at all.isLocalDevHostwould have been the wrong predicate — it returnsfalseforstaging.lvh.me, which would have left that chooser broken.Tests. Hosted roots (
staging/preview/production.veryfront.com,staging.veryfront.org) assert 404; the local hosts assert they keep forwarding with no error context. I confirmed the hosted test fails againstmainbefore trusting it.Not a regression from v0.1.1214 — this predates it; 1214 touched CSP, nanoid and skills, not host routing.
Summary by CodeRabbit
.orgdomains.