Add local deployment detection and .env file instructions - #20
Merged
Conversation
The wizard runs just as well against a checkout on someone's own machine as against a deployment, but every word on the last screen assumed a dashboard and a redeploy — advice a local user cannot follow. `detectHost` now recognises `local`: a dev server always, and a production build reached over loopback, which is `next start` or the compose stack. The `Host` header is the only thing separating that from a self-hosted server on a real domain, so the page passes it in. Locally the closing instructions become the `.env` file and a restart, the database step offers a file URL, and the token field stops insisting one is required. The status page is a different problem: once setup has run, anyone who can reach the site can read it. It no longer prints the site id, and the app check no longer names the id it expected — it says what is wrong without handing over a value. In its place is what the reader actually wants to know at that point: this route has done its job and can be deleted. /setup is also disallowed in robots.txt now. The page already sent `noindex`, but a crawler that never fetches it never sees that. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YK3DzqnUsubgdN3NLgp8D5
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the setup wizard to correctly recognize “local” deployments (dev server or production build served via loopback) and tailor the setup completion instructions accordingly, while also strengthening crawl-prevention for the setup route.
Changes:
- Extend host detection to include a new
localhost type, usingNODE_ENVand loopback hostname parsing from the requestHostheader. - Update setup wizard + success screen copy to instruct local users to update
.envand restart (instead of editing a dashboard and redeploying), including local-friendly DB examples. - Add
/setupto robots disallow rules and enhance setup-route metadata robots directives; expand integration tests accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/int/setup-host.int.spec.ts | Adds comprehensive host-detection coverage, including local cases and NODE_ENV control. |
| tests/int/robots.int.spec.ts | Verifies /setup is disallowed in robots rules. |
| src/app/robots.ts | Disallows /setup and clarifies rationale in comments. |
| src/app/(setup)/setup/wizard.tsx | Adjusts wizard messaging for local vs hosted environments (restart vs redeploy; DB hints). |
| src/app/(setup)/setup/SuccessScreen.tsx | Provides .env + restart instructions for local deployments and adapts related messaging. |
| src/app/(setup)/setup/page.tsx | Passes request Host header into detection; updates post-setup guidance and removes displayed IDs. |
| src/app/(setup)/lib/status.ts | Avoids printing IDs in misconfiguration messages on a publicly reachable page. |
| src/app/(setup)/lib/host.ts | Implements local detection, loopback hostname parsing, and documents behavior. |
| src/app/(setup)/layout.tsx | Strengthens robots metadata (nocache, explicit Googlebot directives) for setup route. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
This PR extends the setup wizard to detect and support local deployments (development servers and self-hosted instances), providing appropriate instructions for configuring environment variables via
.envfiles instead of platform dashboards.Key Changes
Host Detection Enhancement: Added
'local'as a new host type alongside'vercel','netlify', and'unknown'NODE_ENV !== 'production') as localrequestHostparameter to distinguish self-hosted servers from loopback deploymentshostnameOf()helper to parse hostnames from request headers, handling IPv6 literals correctlySuccess Screen Customization: Updated
SuccessScreento provide context-appropriate instructions.envfile instructions for local deployments instead of dashboard/redeploy stepsSetup Wizard Improvements: Customized wizard flow for local development
file:./payload.db)Configuration Page Updates: Enhanced post-setup page for local deployments
SEO & Security: Improved robots.txt and metadata handling
/setupto robots disallow list (page accepts credentials and reports configuration)nocacheand explicit Googlebot directivesTest Coverage: Comprehensive test suite for host detection
hostEnvUrl()returning null for local deploymentsImplementation Details
The
detectHost()function now accepts an optionalrequestHostparameter (typically from the HTTPHostheader) to distinguish between:The loopback detection uses a hostname set for exact matches and suffix matching for
.localhostdomains, properly handling IPv6 bracket notation and port parsing.https://claude.ai/code/session_01YK3DzqnUsubgdN3NLgp8D5