Skip to content

Conversation

@Abhik-Mudi
Copy link

@Abhik-Mudi Abhik-Mudi commented Dec 5, 2025

Closes #216

Summary

Updated vite.config.js to use 127.0.0.1 instead of localhost for the API proxy target.

Why is this change necessary?

On Windows and systems using Node.js v17+, localhost often resolves to the IPv6 address ::1.
Since Uvicorn (FastAPI) listens on 127.0.0.1 (IPv4) by default, this mismatch causes ECONNREFUSED errors during local development.

What does this fix?

  • Ensures the frontend proxy correctly finds the backend on all environments.
  • Eliminates the ECONNREFUSED ::1:8000 error.
  • Verified to work on standard IPv4 and IPv6-enabled networks (as it relies on the local loopback interface).

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • Chores
    • Updated development server proxy configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Walkthrough

The Vite development server proxy target for API requests is updated from http://localhost:8000 to http://127.0.0.1:8000. This explicitly specifies the IPv4 address instead of relying on hostname resolution to address connection failures on Windows with Node 18+.

Changes

Cohort / File(s) Change Summary
Vite proxy configuration
Frontend/vite.config.ts
Updated dev server proxy target from localhost to 127.0.0.1 to resolve IPv6 resolution issues on Windows

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

  • Single line configuration change in one file
  • No logic or control flow modifications

Poem

🐰 A Windows dev woke with a sigh,
Localhost was wearing IPv6 disguise,
Then 127.0.0.1 came to save the day,
Now Vite proxies without delay! ✨
Node 18+ bows to the address so true.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: updating the proxy target to 127.0.0.1 to fix ECONNREFUSED errors, which matches the core modification in vite.config.ts.
Linked Issues check ✅ Passed The PR directly addresses issue #216 by modifying vite.config.ts to use 127.0.0.1 instead of localhost as the proxy target, which resolves the IPv4/IPv6 mismatch causing ECONNREFUSED errors on Windows with Node.js v17+.
Out of Scope Changes check ✅ Passed The PR contains only a targeted configuration change to vite.config.ts that directly addresses the linked issue; no unrelated or out-of-scope modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3be437 and 15dfe72.

📒 Files selected for processing (1)
  • Frontend/vite.config.ts (1 hunks)
🔇 Additional comments (1)
Frontend/vite.config.ts (1)

16-16: IPv6/IPv4 resolution fix is correct—explicitly use 127.0.0.1 to avoid Node.js v17+ resolving localhost to ::1.

The change from localhost to 127.0.0.1 properly resolves the ECONNREFUSED error on Windows by ensuring the Vite proxy connects to the FastAPI backend listening on IPv4. This is the right fix for the stated problem.

Optional: Add an inline comment to document the reason for using the explicit IPv4 address:

     proxy: {
-      '/api': 'http://127.0.0.1:8000',
+      '/api': 'http://127.0.0.1:8000', // Use IPv4 explicitly to avoid Node.js v17+ resolving localhost to ::1
     },

Verify if other references to localhost:8000 exist elsewhere in the codebase that may need similar updates to maintain consistency.


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.

@Abhik-Mudi Abhik-Mudi closed this Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Vite proxy fails with ECONNREFUSED ::1:8000 on Windows/Node 18+

1 participant