feat(dev): prompt for a base URL in setup-env, defaulting to unset - #5385
Open
IamCoder18 wants to merge 1 commit into
Open
feat(dev): prompt for a base URL in setup-env, defaulting to unset#5385IamCoder18 wants to merge 1 commit into
IamCoder18 wants to merge 1 commit into
Conversation
Add a BASE_URL prompt at the start of pnpm dev:setup-env, before the NEXTAUTH_URL prompt. The prompt asks for 'the URL you use to access the dev server' (e.g. http://192.168.1.82:3100 for LAN testing, https://clouddev.example.com behind Cloudflare Access). When provided, it becomes the default for the NEXTAUTH_URL prompt — the user can still override it — and APP_URL_OVERRIDE is also written so auth and server-side redirects resolve at the same public origin. Pressing enter at the BASE_URL prompt leaves both unset, so the NEXTAUTH_URL prompt falls back to the http://localhost:3000 example default. CI mode skips the BASE_URL prompt and preserves the existing CI placeholders. APP_URL_OVERRIDE is appended to .env.local since it is not present in .env.local.example; the file-write path already handles that. Both prompts validate the URL: no whitespace/quotes/newlines/'#' (env-reserved), parseable, http or https protocol, non-empty hostname. On invalid input the user gets a non-fatal recovery menu with options to re-enter, accept a suggested fix (e.g. prepend http:// for a protocol-less host:port), or fall back to the default / clear — no fatal errors.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Reviewed by grok-4.6 · Input: 120.8K · Output: 21.3K · Cached: 246K Review guidance: REVIEW.md from base branch |
Contributor
Author
|
Ready for review! |
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
pnpm dev:setup-envnow prompts for aBASE_URL("the URL you use to access the dev server") at the start, before theNEXTAUTH_URLprompt. When provided, it becomes the default forNEXTAUTH_URL(which the user can still override) andAPP_URL_OVERRIDEis also written so auth and server-side redirects resolve at the same public origin — useful for LAN testing (http://192.168.1.82:3100) and dev URLs behind Cloudflare Access (https://clouddev.example.com). Pressing enter leaves both unset, soNEXTAUTH_URLfalls back to thehttp://localhost:3000example default. CI mode (--ci) skips theBASE_URLprompt and preserves the existing CI placeholders.Both prompts share a URL validator with a non-fatal recovery menu (no fatal exit):
#(env-reserved), unparseable input, non-http/https protocol, missing hostname.192.168.1.82:3100→http://192.168.1.82:3100).[r] Re-enter/[s] Use suggested(when available) /[d] Use default or clear. Enter defaults tod.APP_URL_OVERRIDEis appended to.env.localsince it isn't in.env.local.example; the file-write path already handles that.Verification
pnpm exec oxlint dev/local/setup-env.ts— 0 warnings, 0 errors.pnpm exec tsc --noEmit --target es2022 --module nodenext --moduleResolution nodenext --strict --skipLibCheck dev/local/setup-env.ts— clean.validateUrlhelper vianode -eagainst 10 inputs covering valid LAN/Cloudflare-Access/localhost URLs, protocol-less host:port (suggestshttp://prefix), wrong protocol (ftp:), garbage strings, whitespace, and#-fragment inputs. All produce the expectedok/error/suggestionresult.dev/local/setup-env.tsin the repo, so the prompt flow itself was not exercised end-to-end.pnpm format:check,pnpm lint,pnpm typecheck --changes-only) ran clean on push.Visual Changes
N/A
Reviewer Notes
validateUrlreturns the user's exact input (notparsed.origin) on success, so what you type is what gets written to.env.local. The runtime already derives.originwhen it readsAPP_URL_OVERRIDE/NEXTAUTH_URLvianew URL(...).origin, so a trailing path is harmless — but I chose not to silently rewrite the value. Happy to normalize to origin (reject paths/queries) if you'd rather enforce the strict origin form.''. The caller maps''to the appropriate fallback: empty forBASE_URL(unset), the shown default forNEXTAUTH_URL(base URL orhttp://localhost:3000). So one recovery path serves both prompts.http://" path only fires when the input contains no://. It does not try to fix typos likehtttp://or missing single slashes — those surface as a parse error with a re-enter prompt.