Closed
Conversation
- Replace || with ?? in AuthCallbackContent.tsx - Replace || with ?? in UserInputArea.tsx - Replace || with ?? in GoogleOAuthButton.tsx - Replace || with ?? in AddressAutocomplete.tsx - Replace || with ?? in publicApiSlice.ts - Replace || with ?? in axiosBaseQuery.ts - Fix useEffect dependency in AddressAutocomplete.tsx - Remove console.log statements in AuthCallbackContent.tsx
- Create unified getApiBaseUrl() utility function - Remove hardcoded localhost fallbacks from all files - Production environment now requires API URL to be configured - Development environment allows localhost fallback with warning - Improves code quality and prevents production misconfigurations Files updated: - src/utils/api-config.ts (new) - src/services/places.ts - src/lib/axiosBaseQuery.ts - src/features/public/publicApiSlice.ts - src/components/GoogleOAuthButton.tsx - src/app/(public)/blogs/page.tsx - src/app/(public)/blogs/components/BlogList.tsx - src/app/(public)/blogs/[id]/page.tsx
- Remove unnecessary NEXT_PUBLIC_API_BASE_URL fallback - Use only NEXT_PUBLIC_API_URL as it's the actual configured variable - Simplify code and error messages
- Change from NEXT_PUBLIC_API_URL to NEXT_PUBLIC_API_BASE_URL - This matches the actual configured environment variable name
- Keep same behavior as before: NEXT_PUBLIC_API_BASE_URL ?? localhost fallback - Remove production environment check to match original usage - Environment variable name unchanged: NEXT_PUBLIC_API_BASE_URL - Function only provides centralized management, no behavior change
…upport - Restore NEXT_PUBLIC_API_BASE_URL and NEXT_PUBLIC_API_URL support - Keep function for centralized management - Match original behavior exactly
- Replace getApiBaseUrl() with process.env.NEXT_PUBLIC_API_BASE_URL - Ensure environment variable names match main branch exactly
- Change 'next dev -p 3000' back to 'next dev' to match main branch
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes onboarding functionality by improving API configuration management, enhancing type safety for handling undefined values, and adding validation for OAuth callback data.
Key changes:
- Centralized API base URL configuration with fallback to localhost for development
- Enhanced null/undefined handling throughout the onboarding flow, particularly for user input fields
- Added validation for OAuth user data to prevent invalid states during authentication
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/api-config.ts |
New utility function to centralize API base URL retrieval with environment variable fallback |
src/lib/axiosBaseQuery.ts |
Updated to use fallback for API base URL and changed operator from || to ?? for method defaulting |
src/features/public/publicApiSlice.ts |
Added fallback value for API base URL to handle undefined environment variable |
src/components/ui/AddressAutocomplete.tsx |
Enhanced to accept undefined values, improved address formatting for Australian addresses, and added external value synchronization |
src/app/onboarding/components/UserInputArea.tsx |
Updated to handle undefined userInput values with proper null checking and coalescing |
src/app/auth/callback/AuthCallbackContent.tsx |
Added validation for parsed user data and fallback values for optional user fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/lib/axiosBaseQuery.ts
Outdated
| { url, method = 'GET', data, params, headers }, | ||
| { dispatch, getState }, | ||
| ) => { | ||
| const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL ?? 'http://localhost:4000/api'; |
There was a problem hiding this comment.
A utility function getApiBaseUrl() was created in src/utils/api-config.ts to centralize the API base URL retrieval logic, but it's not being used here. Instead, the same logic is duplicated inline. Consider importing and using the utility function to avoid duplication and maintain consistency.
…access - Replace all direct process.env.NEXT_PUBLIC_API_BASE_URL usage with getApiBaseUrl() - Centralize API base URL logic in api-config.ts - Improve code consistency and maintainability
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.
Fix onboarding!