fixed login session for user name, and updated the api calls on the product detials pages.
CI / test (push) Successful in 6s
CI / test (push) Successful in 6s
This commit is contained in:
@@ -50,9 +50,12 @@ export default function PartsListPageClient(props: {
|
||||
|
||||
// Your current list endpoint:
|
||||
// GET /api/v1/products?platform=AR-15&partRoles=upper-receiver
|
||||
const url = `${API_BASE_URL}/api/v1/products?platform=${encodeURIComponent(platform)}&partRoles=${encodeURIComponent(partRole)}`;
|
||||
const url = `/api/catalog/products?platform=${encodeURIComponent(platform)}&partRoles=${encodeURIComponent(partRole)}`;
|
||||
|
||||
const res = await fetch(url, { headers: { Accept: "application/json" } });
|
||||
const res = await fetch(url, {
|
||||
headers: { Accept: "application/json" },
|
||||
credentials: 'include',
|
||||
});
|
||||
if (!res.ok) {
|
||||
const txt = await res.text().catch(() => "");
|
||||
throw new Error(`Failed to load products (${res.status}): ${txt}`);
|
||||
|
||||
@@ -41,8 +41,9 @@ async function fetchProductDetail(params: {
|
||||
// ---- Preferred (if you add it): GET /api/v1/products/{id}
|
||||
// If it 404s, we fall back.
|
||||
try {
|
||||
const res = await fetch(`${API_BASE_URL}/api/v1/products/${encodeURIComponent(id)}`, {
|
||||
const res = await fetch(`/api/catalog/products/${encodeURIComponent(id)}`, {
|
||||
headers: { Accept: "application/json" },
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
@@ -54,8 +55,8 @@ async function fetchProductDetail(params: {
|
||||
|
||||
// ---- Fallback: use list endpoint + find by id (works right now with your current API)
|
||||
const listRes = await fetch(
|
||||
`${API_BASE_URL}/api/v1/products?platform=${encodeURIComponent(platform)}&partRoles=${encodeURIComponent(partRole)}`,
|
||||
{ headers: { Accept: "application/json" } }
|
||||
`/api/catalog/products?platform=${encodeURIComponent(platform)}&partRoles=${encodeURIComponent(partRole)}`,
|
||||
{ headers: { Accept: "application/json" }, credentials: 'include' }
|
||||
);
|
||||
|
||||
if (!listRes.ok) {
|
||||
|
||||
Reference in New Issue
Block a user