Skip to content

fix: correct post-login redirect route#250

Open
Kannu20 wants to merge 1 commit into
GitMetricsLab:mainfrom
Kannu20:fix-login-redirect
Open

fix: correct post-login redirect route#250
Kannu20 wants to merge 1 commit into
GitMetricsLab:mainfrom
Kannu20:fix-login-redirect

Conversation

@Kannu20
Copy link
Copy Markdown

@Kannu20 Kannu20 commented May 15, 2026

Related Issue

Closes #244


Description

Fixed authentication API request failures caused by an undefined backend URL.

Changes made:

  • Added proper VITE_BACKEND_URL usage
  • Fixed signup API endpoint configuration
  • Fixed login API endpoint configuration
  • Corrected post-login redirect behavior to /home
  • Verified frontend-backend communication on localhost:5000

How Has This Been Tested?

  • Tested signup functionality
  • Tested login functionality
  • Verified successful API requests
  • Verified redirect after login
  • Checked browser console for errors

Type of Change

  • Bug fix

Summary by CodeRabbit

  • Bug Fixes
    • Updated the login flow to redirect to the home page upon successful authentication.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 984d4e2
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a06c95997fedf000890bb5d
😎 Deploy Preview https://deploy-preview-250--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

Small targeted updates to authentication flows: added debug logging in signup to diagnose backend URL resolution, corrected post-login navigation route from "/home" to "/", and cleaned environment configuration examples by removing obsolete sample entries.

Changes

Authentication Flow Updates

Layer / File(s) Summary
Signup backend URL debug logging
src/pages/Signup/Signup.tsx
handleSubmit now logs backendUrl and import.meta.env.VITE_BACKEND_URL to console before the signup API request, aiding diagnosis of the undefined backend URL issue reported in #244.
Login post-success navigation
src/pages/Login/Login.tsx
Successful login now navigates to "/" instead of "/home" when the backend response message matches "Login successful".
Environment configuration cleanup
.env.example, backend/.env.sample
Removed example VITE_BACKEND_URL entry from frontend config and cleared sample environment variables (PORT, MONGO_URI, SESSION_SECRET) from backend config.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A rabbit hops through auth so fine,
Debug logs help the URLs align,
Home becomes root, config gets lean,
Login flows smooth—no undefined scene!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'fix: correct post-login redirect route' is specific but only addresses one minor change; the primary fix involves resolving undefined backend URL issues affecting signup/login API requests, which is not reflected in the title. Revise the title to emphasize the main objective: 'fix: resolve undefined backend URL in authentication requests' or similar, reflecting the core issue being addressed.
Out of Scope Changes check ⚠️ Warning The removal of .env.example and backend/.env.sample entries appears unrelated to fixing the undefined backend URL API issue, and debug logging in Signup.tsx exceeds the stated objectives. Remove unrelated changes: revert environment file removals unless directly required to fix the backend URL configuration, and remove debug logging console statements from Signup.tsx unless explicitly required by issue #244.
Linked Issues check ❓ Inconclusive The changes partially address issue #244 by modifying environment configuration and login redirect, but the removal of backend URL examples and debug logging additions do not fully resolve the undefined API base URL root cause. Clarify whether the backend URL configuration in environment files now properly prevents 'undefined/api/auth/signup' errors and verify that the debug logging confirms correct VITE_BACKEND_URL resolution during runtime.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description covers most required sections from the template and provides context for the bug fix, though the testing details are somewhat generic and could be more specific.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Thank you @Kannu20 for your contribution. Please make sure your PR follows https://github.com/GitMetricsLab/github_tracker/blob/main/CONTRIBUTING.md#-pull-request-guidelines

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pages/Signup/Signup.tsx (1)

27-28: ⚡ Quick win

Remove debug logging before production.

These console.log statements were added to diagnose the undefined backend URL issue, but they should not remain in production code. Instead, add validation to ensure backendUrl is defined before making the API request.

♻️ Proposed refactor to replace debug logs with validation
-    console.log("backendUrl:", backendUrl);
-console.log("env:", import.meta.env.VITE_BACKEND_URL);
+    if (!backendUrl) {
+      setMessage("Configuration error: Backend URL is not defined.");
+      return;
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/Signup/Signup.tsx` around lines 27 - 28, Remove the stray
console.log debug lines and add validation around the backend URL used for API
calls: ensure the value referenced as backendUrl (and if applicable
import.meta.env.VITE_BACKEND_URL) is defined and non-empty before performing the
request (e.g., in the Signup component or the function that calls fetch/axios),
and surface a clear user-facing error or throw a descriptive error/log via
processLogger/ui state instead of logging to console; fail-fast so the API call
is not attempted when backendUrl is missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/Login/Login.tsx`:
- Line 37: The PR description incorrectly states the login redirect goes to
"/home" while the code in Login.tsx calls navigate("/") (which routes to the
Home page); update the PR description to state the redirect is to "/" (matching
navigate("/") in Login.tsx and the defined route in Router.tsx) so the PR text
accurately reflects the implementation.

---

Nitpick comments:
In `@src/pages/Signup/Signup.tsx`:
- Around line 27-28: Remove the stray console.log debug lines and add validation
around the backend URL used for API calls: ensure the value referenced as
backendUrl (and if applicable import.meta.env.VITE_BACKEND_URL) is defined and
non-empty before performing the request (e.g., in the Signup component or the
function that calls fetch/axios), and surface a clear user-facing error or throw
a descriptive error/log via processLogger/ui state instead of logging to
console; fail-fast so the API call is not attempted when backendUrl is missing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5833bd4e-af06-4d41-8111-0f5c4f60c975

📥 Commits

Reviewing files that changed from the base of the PR and between 56e17a3 and 984d4e2.

📒 Files selected for processing (4)
  • .env.example
  • backend/.env.sample
  • src/pages/Login/Login.tsx
  • src/pages/Signup/Signup.tsx
💤 Files with no reviewable changes (2)
  • backend/.env.sample
  • .env.example

Comment thread src/pages/Login/Login.tsx

if (response.data.message === 'Login successful') {
navigate("/home");
navigate("/");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find route definitions to verify the correct post-login destination.

# Search for route definitions in the codebase
rg -n --type=tsx --type=ts -A 3 -B 3 'path.*["\']/(home)?' --glob '!node_modules'

Repository: GitMetricsLab/github_tracker

Length of output: 241


🏁 Script executed:

#!/bin/bash
# Search for route definitions and the root path handler
fd -e tsx -e ts | head -20

Repository: GitMetricsLab/github_tracker

Length of output: 629


🏁 Script executed:

#!/bin/bash
# Look for Router/Routes configuration
rg -n "path|Route" --type tsx --type ts -A 2 | head -40

Repository: GitMetricsLab/github_tracker

Length of output: 100


🏁 Script executed:

#!/bin/bash
# Check the App component to see routing setup
fd "App\\.tsx" -o "app\\.tsx" -o "index\\.tsx" | grep -E "(App|app|index)" | head -10

Repository: GitMetricsLab/github_tracker

Length of output: 208


🏁 Script executed:

cat -n src/Routes/Router.tsx

Repository: GitMetricsLab/github_tracker

Length of output: 1271


🏁 Script executed:

cat -n src/App.tsx

Repository: GitMetricsLab/github_tracker

Length of output: 1513


🏁 Script executed:

sed -n '30,45p' src/pages/Login/Login.tsx

Repository: GitMetricsLab/github_tracker

Length of output: 478


Correct the PR description to match the code.

The code correctly navigates to "/" (which displays the Home page), but the PR description incorrectly states the redirect is to "/home". There is no /home route defined in the application—only / (line 14 of src/Routes/Router.tsx). Update the PR description to accurately reflect that the redirect is to "/", not "/home".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/Login/Login.tsx` at line 37, The PR description incorrectly states
the login redirect goes to "/home" while the code in Login.tsx calls
navigate("/") (which routes to the Home page); update the PR description to
state the redirect is to "/" (matching navigate("/") in Login.tsx and the
defined route in Router.tsx) so the PR text accurately reflects the
implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Signup/Login requests fail due to undefined API base URL

1 participant