-
Notifications
You must be signed in to change notification settings - Fork 1
Change backend and frontend API port from 3001 to 3111 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,4 @@ | ||||||||||||||||||||||
| // INTENTIONAL BUG (Exercise 2): port should be 3001, not 3002 | ||||||||||||||||||||||
| const BASE_URL = 'http://localhost:3002/api'; | ||||||||||||||||||||||
| const BASE_URL = 'http://localhost:3111/api'; | ||||||||||||||||||||||
|
||||||||||||||||||||||
| const BASE_URL = 'http://localhost:3111/api'; | |
| const DEFAULT_BASE_URL = 'http://localhost:3111/api'; | |
| const INTENTIONAL_BUG_BASE_URL = 'http://localhost:3000/api'; | |
| const USE_INTENTIONAL_API_PORT_BUG = | |
| import.meta.env.VITE_USE_INTENTIONAL_API_PORT_BUG === 'true'; | |
| const BASE_URL = USE_INTENTIONAL_API_PORT_BUG | |
| ? INTENTIONAL_BUG_BASE_URL | |
| : DEFAULT_BASE_URL; |
Copilot
AI
Apr 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BASE_URL is hardcoded to http://localhost:3111/api, which ties the frontend bundle to a single dev host/port and bypasses the Vite /api proxy configuration. Consider using a relative base (e.g., /api) and relying on the dev proxy (or sourcing the base URL from a VITE_ env var) so the backend port can be changed in one place and deployments aren’t coupled to localhost.
| const BASE_URL = 'http://localhost:3111/api'; | |
| export async function apiFetch<T>(path: string, options?: RequestInit): Promise<T> { | |
| const response = await fetch(`${BASE_URL}${path}`, { | |
| const BASE_URL = (import.meta.env.VITE_API_BASE_URL as string | undefined) ?? '/api'; | |
| export async function apiFetch<T>(path: string, options?: RequestInit): Promise<T> { | |
| const normalizedBaseUrl = BASE_URL.endsWith('/') ? BASE_URL.slice(0, -1) : BASE_URL; | |
| const normalizedPath = path.startsWith('/') ? path : `/${path}`; | |
| const response = await fetch(`${normalizedBaseUrl}${normalizedPath}`, { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ export default defineConfig({ | |
| port: 5173, | ||
| proxy: { | ||
| '/api': { | ||
| target: 'http://localhost:3001', | ||
| target: 'http://localhost:3111', | ||
| changeOrigin: true, | ||
| }, | ||
|
Comment on lines
9
to
12
|
||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the backend default port to
3111will break existing E2E/CI wiring that still targets3001(e.g.,e2e/playwright.config.tswebServerurland.github/workflows/e2e.ymlwait-on/PORTvalues). Please update those configurations (or keep the default port aligned) to avoid CI and Playwright startup failures.