Skip to content

Change backend and frontend API port from 3001 to 3111#2

Open
walwiljorn wants to merge 1 commit intomainfrom
fix/port-3001-to-3111
Open

Change backend and frontend API port from 3001 to 3111#2
walwiljorn wants to merge 1 commit intomainfrom
fix/port-3001-to-3111

Conversation

@walwiljorn
Copy link
Copy Markdown
Collaborator

No description provided.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 PORT fallback to 3111.

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.

Comment on lines +1 to 4
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}`, {
Copy link

Copilot AI Apr 18, 2026

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.

Suggested change
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}`, {

Copilot uses AI. Check for mistakes.
@@ -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';
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines 9 to 12
'/api': {
target: 'http://localhost:3001',
target: 'http://localhost:3111',
changeOrigin: true,
},
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.

const app = express();
const PORT = process.env.PORT ?? 3001;
const PORT = process.env.PORT ?? 3111;
Copy link

Copilot AI Apr 18, 2026

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 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.

Suggested change
const PORT = process.env.PORT ?? 3111;
const PORT = process.env.PORT ?? 3001;

Copilot uses AI. Check for mistakes.
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.

2 participants