fix(frontend): fix step numbering and client-side API base URL
- Step numbers now use each-block index (i+1) instead of order_index+1, fixing display when order_index starts from 1 in existing data - api.ts: browser-side requests use /api (nginx proxy) instead of PUBLIC_API_BASE (localhost:8000), fixing PATCH/client calls on remote hosts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5cb44b2c65
commit
d4e3040674
2 changed files with 7 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { browser } from '$app/environment';
|
||||
import { PUBLIC_API_BASE } from '$env/static/public';
|
||||
import type {
|
||||
ActiveIngredient,
|
||||
|
|
@ -21,7 +22,10 @@ import type {
|
|||
// ─── Core fetch helpers ──────────────────────────────────────────────────────
|
||||
|
||||
async function request<T>(path: string, init: RequestInit = {}): Promise<T> {
|
||||
const url = `${PUBLIC_API_BASE}${path}`;
|
||||
// Server-side uses PUBLIC_API_BASE (e.g. http://localhost:8000).
|
||||
// Browser-side uses /api so nginx proxies the request on the correct host.
|
||||
const base = browser ? '/api' : PUBLIC_API_BASE;
|
||||
const url = `${base}${path}`;
|
||||
const res = await fetch(url, {
|
||||
headers: { 'Content-Type': 'application/json', ...init.headers },
|
||||
...init
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue