Repository navigation
Fail the build when NEXT_PUBLIC_API_URL is missing or invalid - #434
Merged
Merged
Conversation
|
@olufunsoolutayo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@olufunsoolutayo is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
- Narrow apiUrl by checking it in the failure guard instead of casting it with `as string`. - Import the env module as @/lib/env like the rest of lib/ (next.config.ts keeps its relative import, since the alias is not available there). - Add the missing trailing newline to lib/env.ts.
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.
Closes #406
What changed
lib/env.tsvalidates the public environment once, at import time:NEXT_PUBLIC_API_URLis required and must be an absolutehttp(s)URL.NEXT_PUBLIC_SITE_URLandNEXT_PUBLIC_BOUNDLESS_APP_URLare optional (they keep their fallbacks inlib/seo/site.ts), but must be absolutehttp(s)URLs when set..env.exampleto.env.local.next.config.tsimports it, so bothnext buildandnext devfail before compiling anything.lib/api/client.tsandlib/seo/site.tsread the values frompublicEnv, solib/env.tsis the only file that readsprocess.env.NEXT_PUBLIC_*. Trailing-slash trimming is unchanged.Verification
npm run buildwithNEXT_PUBLIC_API_URLunsetNEXT_PUBLIC_API_URLNEXT_PUBLIC_API_URL=not-a-url npm run buildNEXT_PUBLIC_SITE_URL=ftp://x,NEXT_PUBLIC_BOUNDLESS_APP_URL=nopenpm run buildwith the.env.examplevaluesnpm run devwithout the variablenpm run lint,npx tsc --noEmit,npm run buildandnpm run seo:checkpass. The API origin is inlined into the client bundle and no chunk readsprocess.envat runtime.