From 0deee170310e9b13b2970a3cd29cf7e59cf54ce8 Mon Sep 17 00:00:00 2001 From: Amritanshu Date: Thu, 17 Oct 2024 08:43:02 +0530 Subject: [PATCH] Remove generateStaticParams to enable compiling. Else, it sets the url as localhost in the deployement or does not build as it cannot access the container during build. --- .../(storefront)/products/[handle]/page.tsx | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/app/(storefront)/products/[handle]/page.tsx b/src/app/(storefront)/products/[handle]/page.tsx index 78796eb..8d53a60 100644 --- a/src/app/(storefront)/products/[handle]/page.tsx +++ b/src/app/(storefront)/products/[handle]/page.tsx @@ -1,4 +1,4 @@ -import { HttpTypes } from '@medusajs/types'; +// import { HttpTypes } from '@medusajs/types'; import { FC } from 'react'; import ProductDetails from './ProductDetails'; @@ -8,27 +8,27 @@ interface ProductPageProps { handle: string; }; } -export async function generateStaticParams() { - // Fetch the list of products - const products: HttpTypes.StoreProduct[] = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/products`, { - credentials: 'include', - headers: { - 'Content-Type': 'application/json', - 'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string, - }, - }) - .then((res) => res.json()) - .then((data) => data.products); +// export async function generateStaticParams() { +// // Fetch the list of products +// const products: HttpTypes.StoreProduct[] = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/products`, { +// credentials: 'include', +// headers: { +// 'Content-Type': 'application/json', +// 'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string, +// }, +// }) +// .then((res) => res.json()) +// .then((data) => data.products); - if (!products) { - return []; - } - // Generate static params based on product handles - const staticParams = products.map((product) => ({ - handle: product.handle, - })); - return staticParams; -} +// if (!products) { +// return []; +// } +// // Generate static params based on product handles +// const staticParams = products.map((product) => ({ +// handle: product.handle, +// })); +// return staticParams; +// } const ProductPage: FC = ({ params }) => { const { handle } = params; // Extract the handle from the params