env edited
This commit is contained in:
@@ -9,9 +9,23 @@
|
||||
import type { FiestaEnvelope } from './types';
|
||||
|
||||
/**
|
||||
* In dev, Vite proxies `/fiesta` -> https://fiesta.nearle.app (see
|
||||
* vite.config.ts), which keeps the network tab honest and sidesteps preflight
|
||||
* surprises. In production the deployed host is set by VITE_API_BASE.
|
||||
* Where Fiesta is.
|
||||
*
|
||||
* Set in `.env` as `VITE_API_BASE`, so the host is declared in one place rather
|
||||
* than inferred here — Vite compiles it into the bundle at build time and both
|
||||
* `npm run dev` and a deployed build use the same value.
|
||||
*
|
||||
* This module briefly decided the host itself, switching on `import.meta.env.DEV`.
|
||||
* Explicit configuration is better: a rule in code that says "development means
|
||||
* this, production means that" is invisible from the outside, and someone
|
||||
* reading `.env` to find the backend would have found nothing.
|
||||
*
|
||||
* The `'/fiesta'` fallback is for a build with no `.env` at all. It routes
|
||||
* through the dev proxy (`vite.config.ts`) or nginx (`nginx.conf.template`),
|
||||
* both of which forward to the same host — so a missing variable degrades to a
|
||||
* working same-origin path rather than to a broken one.
|
||||
*
|
||||
* Override per machine with `.env.local`, which is gitignored.
|
||||
*/
|
||||
export const API_BASE = import.meta.env['VITE_API_BASE'] ?? '/fiesta';
|
||||
|
||||
|
||||
@@ -38,13 +38,25 @@ export interface LocationProductQuery {
|
||||
}
|
||||
|
||||
export const productsApi = {
|
||||
/** A store's own catalogue — what is actually imported, with live stock. */
|
||||
/**
|
||||
* A store's own catalogue — what is actually imported, with live stock.
|
||||
*
|
||||
* `pageno` is 1-BASED on the backend: `GetLocationProducts` clamps anything
|
||||
* below 1 up to 1 (`productRepository.go:453`). So page 0 and page 1 both
|
||||
* return the first page, and a caller counting from zero fetches page one
|
||||
* twice and never sees the last one. The `+ 1` here is what makes a 0-based
|
||||
* caller correct rather than off by one.
|
||||
*
|
||||
* `pagesize` defaults to 200 rather than 50 because nothing in the console
|
||||
* paginates this yet: both call sites ask for one page and render it, so a
|
||||
* shop with 80 products was showing 50 and silently dropping the rest.
|
||||
*/
|
||||
locationProducts: (query: LocationProductQuery) =>
|
||||
api.list<Product>(`${WEB}/products/getlocationproducts`, {
|
||||
tenantid: query.tenantid,
|
||||
locationid: query.locationid,
|
||||
pageno: query.pageno ?? 0,
|
||||
pagesize: query.pagesize ?? 50,
|
||||
pageno: (query.pageno ?? 0) + 1,
|
||||
pagesize: query.pagesize ?? 200,
|
||||
}),
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user