Fix CORS blocking and add graceful Firebase initialization #18
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.
Frontend requests from
localhost:5174were blocked by CORS policy, and server crashed on missing Firebase credentials.Changes
CORS Configuration
http://localhost:5174for developmentFirebase Initialization
MongoDB Connection
Environment Configuration
.env.exampletemplates documenting all required variables.envfiles with placeholder values (gitignored)Before:
After:
Documentation
Users must still configure their own Firebase and MongoDB credentials in
.envfiles.Original prompt
:5174/:1 Access to XMLHttpRequest at 'http://localhost:3000/api/users/verify' from origin 'http://localhost:5174' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
[Chronological Review: The conversation began with the user requesting to pull the most recent branch of the repository. The user then asked to get the application running for testing. Following that, the user requested an update to the environment file with specific configuration details. The user subsequently requested to restart the application. The conversation then shifted to error messages related to CORS policy and Firebase API key issues, indicating problems encountered while trying to access the application.]useUser.js:13 AxiosError
:3000/api/users/verify:1 Failed to load resource: net::ERR_FAILED
StartProject:1 Access to XMLHttpRequest at 'http://localhost:3000/api/users/verify' from origin 'http://localhost:5174' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
useUser.js:13 AxiosError
:3000/api/users/verify:1 Failed to load resource: net::ERR_FAILED
identitytoolkit.googleapis.com/v1/projects?key=AIzaSyBKGx9x8YZ3QY7cZvK9mF5qJ0oYpxJ8xYo:1 Failed to load resource: the server responded with a status of 400 ()
installHook.js:1 Google Sign-in or verification failed: FirebaseError: Firebase: Error (auth/api-key-not-valid.-please-pass-a-valid-api-key.).
at createErrorInternal (firebase_auth.js?v=bd967ac9:698:37)
at _fail (firebase_auth.js?v=bd967ac9:660:9)
at _performFetchWithErrorHandling (firebase_auth.js?v=bd967ac9:1140:9)
at async _validateOrigin (firebase_auth.js?v=bd967ac9:7351:33)
overrideMethod @ installHook.js:1
www.googleapis.com/identitytoolkit/v3/relyingparty/getProjectConfig?key=AIzaSyBKGx9x8YZ3QY7cZvK9mF5qJ0oYpxJ8xYo&cb=1764001400089:1 Failed to load resource: the server responded with a status of 400 ()
iframe.js:311 {"error":{"code":400,"message":"API key not valid. Please pass a valid API key.","errors":[{"message":"API key not valid. Please pass a valid API key.","domain":"global","reason":"badRequest"}],"status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"API_KEY_INVALID","domain":"googleapis.com","metadata":{"service":"identitytoolkit.googleapis.com"}},{"@type":"type.googleapis.com/google.rpc.LocalizedMessage","locale":"en-US","message":"API key not valid. Please pass a valid API key."}]}}
kl @ iframe.js:311
installHook.js:1 Login failed: FirebaseError: Firebase: Error (auth/api-key-not-valid.-please-pass-a-valid-api-key.).
at createErrorInternal (firebase_auth.js?v=bd967ac9:698:37)
at _fail (firebase_auth.js?v=bd967ac9:660:9)
at _performFetchWithErrorHandling (firebase_auth.js?v=bd967ac9:1140:9)
at async _validateOrigin (firebase_auth.js?v=bd967ac9:7351:33)
overrideMethod @ installHook.js:1
handleLogin @ AffiliateSignup.jsx:69
await in handleLogin
callCallback2 @ chunk-SXRIVT2P.js?v=bd967ac9:3680
invokeGuardedCallbackDev @ chunk-SXRIVT2P.js?v=bd967ac9:3705
invokeGuardedCallback @ chunk-SXRIVT2P.js?v=bd967ac9:3739
invokeGuardedCallbackAndCatchFirstError @ chunk-SXRIVT2P.js?v=bd967ac9:3742
executeDispatch @ chunk-SXRIVT2P.js?v=bd967ac9:7046
processDispatchQueueItemsInOrder @ chunk-SXRIVT2P.js?v=bd967ac9:7066
processDispatchQueue @ chunk-SXRIVT2P.js?v=bd967ac9:7075
dispatchEventsForPlugins @ chunk-SXRIVT2P.js?v=bd967ac9:7083
(anonymous) @ chunk-SXRIVT2P.js?v=bd967ac9:7206
batchedUpdates$1 @ chunk-SXRIVT2P.js?v=bd967ac9:18966
batchedUpdates @ chunk-SXRIVT2P.js?v=bd967ac9:3585
dispatchEventForPluginEventSystem @ chunk-SXRIVT2P.js?v=bd967ac9:7205
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ chunk-SXRIVT2P.js?v=bd967ac9:5484
dispatchEvent @ chunk-SXRIVT2P.js?v=bd967ac9:5478
dispatchDiscreteEvent @ chunk-SXRIVT2P.js?v=bd967ac9:5455
[Intent Mapping:
[Technical Inventory:
[Code Archaeology:
[Progress Assessment:
Created from VS Code via the GitHub Pull Request extension.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.