Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6a92f75ea | ||
|
|
0eea6234d6 | ||
|
|
77bf6089fb | ||
|
|
0134a4dd0b | ||
|
|
3fe63591ec | ||
|
|
c6cf394c26 | ||
|
|
7a09202c27 | ||
|
|
a902dc0a26 | ||
|
|
04dc6bd8bc | ||
|
|
60072cfcbe |
@@ -25,6 +25,16 @@ module.exports = defineConfig({
|
||||
jwtSecret: required("JWT_SECRET"),
|
||||
cookieSecret: required("COOKIE_SECRET"),
|
||||
},
|
||||
// Todos los Ingress del lab terminan en Traefik por HTTP plano
|
||||
// (entrypoint "web", sin TLS); Cloudflare es quien atiende HTTPS de
|
||||
// cara al navegador. Con `secure: true` (el default en producción),
|
||||
// express-session nunca emite Set-Cookie porque no detecta la
|
||||
// conexión como HTTPS, y el dashboard admin queda con 401 en
|
||||
// /admin/users/me pese a loguear bien. La API con Bearer token no se
|
||||
// ve afectada por esto.
|
||||
cookieOptions: {
|
||||
secure: false,
|
||||
},
|
||||
},
|
||||
|
||||
admin: {
|
||||
|
||||
@@ -9,10 +9,17 @@ import { getProductBySlug, getProducts } from "@/lib/headless/client";
|
||||
|
||||
interface ProductPageProps { params: Promise<{ slug: string }> }
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const products = await getProducts();
|
||||
return products.map((product) => ({ slug: product.slug }));
|
||||
}
|
||||
// generateStaticParams + revalidate quedaban aquí para pre-renderizar en
|
||||
// build time, pero HEADLESS_PROVIDER/MEDUSA_* no existen en el contexto del
|
||||
// Docker build: el snapshot estático quedaba congelado con el catálogo mock
|
||||
// (todos los productos con price: null) hasta que ISR lo revalidara. Con
|
||||
// frontend-deploy corriendo 2 réplicas y sin cacheHandler compartido, cada
|
||||
// pod revalida su propia caché de forma independiente, así que un producto
|
||||
// podía mostrar "Consultar precio" en un pod y el precio real en el otro
|
||||
// según cuál hubiera sido "calentado". force-dynamic elimina esa caché por
|
||||
// pod y deja esta ruta en vivo contra Medusa, igual que el listado
|
||||
// (dinámico por searchParams).
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function generateMetadata({ params }: ProductPageProps): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
|
||||
@@ -52,7 +52,7 @@ spec:
|
||||
memory: 64Mi
|
||||
|
||||
- name: migrations
|
||||
image: gitea.cruzcloud.net/devops/ecommerce-medusa:v1.0.85
|
||||
image: gitea.cruzcloud.net/devops/ecommerce-medusa:v1.0.88
|
||||
imagePullPolicy: IfNotPresent
|
||||
command:
|
||||
- npx
|
||||
@@ -73,7 +73,7 @@ spec:
|
||||
|
||||
containers:
|
||||
- name: medusa
|
||||
image: gitea.cruzcloud.net/devops/ecommerce-medusa:v1.0.85
|
||||
image: gitea.cruzcloud.net/devops/ecommerce-medusa:v1.0.88
|
||||
imagePullPolicy: IfNotPresent
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
|
||||
@@ -16,7 +16,7 @@ spec:
|
||||
- name: gitea-registry-secret
|
||||
containers:
|
||||
- name: web
|
||||
image: gitea.cruzcloud.net/devops/ecommerce-frontend:v1.0.77
|
||||
image: gitea.cruzcloud.net/devops/ecommerce-frontend:v1.0.87
|
||||
ports:
|
||||
- containerPort: 80
|
||||
env:
|
||||
@@ -24,6 +24,8 @@ spec:
|
||||
value: medusa
|
||||
- name: MEDUSA_BACKEND_URL
|
||||
value: http://medusa-svc:9000
|
||||
- name: MEDUSA_REGION_ID
|
||||
value: reg_01KZT86WPAH7A7ZZRDSX3350V2
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: commerce-storefront
|
||||
|
||||
@@ -258,6 +258,14 @@ function backendUrl(): string {
|
||||
return value.replace(/\/$/, "");
|
||||
}
|
||||
|
||||
function regionId(): string {
|
||||
const value = process.env.MEDUSA_REGION_ID;
|
||||
if (!value) {
|
||||
throw new Error("MEDUSA_REGION_ID no está configurado.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
async function medusaFetch<T>(
|
||||
path: string,
|
||||
searchParams?: URLSearchParams,
|
||||
@@ -515,7 +523,10 @@ async function fetchProducts(
|
||||
): Promise<Product[]> {
|
||||
const params = new URLSearchParams({
|
||||
limit: String(limit),
|
||||
currency_code: "cop",
|
||||
// El validador de /store/products no acepta currency_code (400
|
||||
// "Unrecognized fields"); el precio calculado solo se resuelve con
|
||||
// region_id.
|
||||
region_id: regionId(),
|
||||
fields:
|
||||
"+metadata,+images,+tags,+categories,+collection,+variants.inventory_quantity,+variants.calculated_price,+variants.options",
|
||||
});
|
||||
@@ -543,7 +554,10 @@ export const medusaCatalogProvider: CatalogProvider = {
|
||||
const params = new URLSearchParams({
|
||||
handle: slug,
|
||||
limit: "1",
|
||||
currency_code: "cop",
|
||||
// El validador de /store/products no acepta currency_code (400
|
||||
// "Unrecognized fields"); el precio calculado solo se resuelve con
|
||||
// region_id.
|
||||
region_id: regionId(),
|
||||
fields:
|
||||
"+metadata,+images,+tags,+categories,+collection,+variants.inventory_quantity,+variants.calculated_price,+variants.options",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user