Change backend and frontend API port from 3001 to 3111#2
Change backend and frontend API port from 3001 to 3111#2walwiljorn wants to merge 1 commit intomainfrom
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the local development API port across the backend and frontend configuration to use 3111 instead of 3001, aligning the dev server proxy and API client with the backend’s new default port.
Changes:
- Update Vite dev server proxy target to
http://localhost:3111. - Update frontend API client base URL to
http://localhost:3111/api(and remove the “intentional bug” note). - Update backend default
PORTfallback to3111.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| claude-code-generated/frontend/vite.config.ts | Points Vite /api proxy at the backend’s new port (3111). |
| claude-code-generated/frontend/src/api/client.ts | Changes frontend API base URL to 3111 and removes the exercise note. |
| claude-code-generated/backend/src/index.ts | Changes backend default port fallback to 3111. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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}`, { |
There was a problem hiding this comment.
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}`, { |
| @@ -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'; | |||
There was a problem hiding this comment.
This change removes the “intentional bug” note and sets the API client to a correct port; however, repo docs still describe an exercise where the API client port is intentionally wrong (see README/CLAUDE references to “Oppgave 2”). Either keep the intentional misconfiguration behind a flag/branch, or update the workshop docs so they match the new behavior.
| 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; |
| '/api': { | ||
| target: 'http://localhost:3001', | ||
| target: 'http://localhost:3111', | ||
| changeOrigin: true, | ||
| }, |
There was a problem hiding this comment.
With frontend/src/api/client.ts now using an absolute http://localhost:3111/api base URL, requests won’t go through this Vite /api proxy at all. Either switch the client to use relative /api paths (so this proxy is actually used), or remove the proxy to avoid a misleading configuration.
|
|
||
| const app = express(); | ||
| const PORT = process.env.PORT ?? 3001; | ||
| const PORT = process.env.PORT ?? 3111; |
There was a problem hiding this comment.
Changing the backend default port to 3111 will break existing E2E/CI wiring that still targets 3001 (e.g., e2e/playwright.config.ts webServer url and .github/workflows/e2e.yml wait-on/PORT values). Please update those configurations (or keep the default port aligned) to avoid CI and Playwright startup failures.
| const PORT = process.env.PORT ?? 3111; | |
| const PORT = process.env.PORT ?? 3001; |
No description provided.