fix: auto-detect API URL uses correct port 8001, add useState import to ForgejoIssuesTable (issue #29)

This commit is contained in:
null 2026-05-19 19:22:22 -05:00
parent 4878724bed
commit 2de481460f
7 changed files with 9 additions and 9 deletions

View File

@ -26,6 +26,6 @@ LOCAL_AUTH_TOKEN=
# --- frontend settings ---
# REQUIRED: Public URL used by the browser to reach the API.
# Use `auto` to target the same host currently serving Pipeline on port 8000.
# Use `auto` to target the same host currently serving Pipeline on port 8001.
# Example (explicit override): NEXT_PUBLIC_API_URL=https://mc.example.com
NEXT_PUBLIC_API_URL=auto

View File

@ -92,7 +92,7 @@ Before startup:
- Set `LOCAL_AUTH_TOKEN` to a non-placeholder value (minimum 50 characters) when `AUTH_MODE=local`.
- Ensure `BASE_URL` matches the public backend origin if you are not using `http://localhost:8000`.
- `NEXT_PUBLIC_API_URL=auto` (default) resolves to `http(s)://<current-host>:8000`.
- `NEXT_PUBLIC_API_URL=auto` (default) resolves to `http(s)://<current-host>:8001`.
- Set an explicit URL when your API is behind a reverse proxy or non-default port.
### 2. Start Mission Control

View File

@ -1,5 +1,5 @@
# Base URL for frontend -> backend calls.
# Use `auto` to target the same host currently serving Mission Control on port 8000.
# Use `auto` to target the same host currently serving Mission Control on port 8001.
# Example explicit override: https://mc.example.com
NEXT_PUBLIC_API_URL=auto

View File

@ -46,7 +46,7 @@ The frontend reads configuration from standard Next.js env files (`.env.local`,
Base URL of the backend API (or `auto`).
- Default: `auto` (resolved in browser as `http(s)://<current-host>:8000`)
- Default: `auto` (resolved in browser as `http(s)://<current-host>:8001`)
- Used by the generated API client and helpers (see `src/lib/api-base.ts` and `src/api/mutator.ts`).
Example:
@ -143,7 +143,7 @@ If youre working on self-hosting, prefer running compose from the repo root s
### `NEXT_PUBLIC_API_URL` and remote hosts
If unset or set to `auto`, the client uses `http(s)://<current-host>:8000`.
If unset or set to `auto`, the client uses `http(s)://<current-host>:8001`.
If your backend is on a different host/port, set `NEXT_PUBLIC_API_URL` explicitly.
Fix:

View File

@ -1,6 +1,6 @@
"use client";
import { useMemo } from "react";
import { useMemo, useState } from "react";
import { type ColumnDef, getCoreRowModel, useReactTable } from "@tanstack/react-table";
import { XCircle } from "lucide-react";

View File

@ -16,12 +16,12 @@ describe("getApiBaseUrl", () => {
it("auto-resolves from browser host when set to auto", () => {
vi.stubEnv("NEXT_PUBLIC_API_URL", "auto");
expect(getApiBaseUrl()).toBe("http://localhost:8000");
expect(getApiBaseUrl()).toBe("http://localhost:8001");
});
it("auto-resolves from browser host when unset", () => {
vi.stubEnv("NEXT_PUBLIC_API_URL", "");
expect(getApiBaseUrl()).toBe("http://localhost:8000");
expect(getApiBaseUrl()).toBe("http://localhost:8001");
});
});

View File

@ -12,7 +12,7 @@ export function getApiBaseUrl(): string {
const protocol = window.location.protocol === "https:" ? "https" : "http";
const host = window.location.hostname;
if (host) {
return `${protocol}://${host}:8000`;
return `${protocol}://${host}:8001`;
}
}