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.
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import { HttpTypes } from '@medusajs/types';
|
// import { HttpTypes } from '@medusajs/types';
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
|
|
||||||
import ProductDetails from './ProductDetails';
|
import ProductDetails from './ProductDetails';
|
||||||
@ -8,27 +8,27 @@ interface ProductPageProps {
|
|||||||
handle: string;
|
handle: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export async function generateStaticParams() {
|
// export async function generateStaticParams() {
|
||||||
// Fetch the list of products
|
// // Fetch the list of products
|
||||||
const products: HttpTypes.StoreProduct[] = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/products`, {
|
// const products: HttpTypes.StoreProduct[] = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/store/products`, {
|
||||||
credentials: 'include',
|
// credentials: 'include',
|
||||||
headers: {
|
// headers: {
|
||||||
'Content-Type': 'application/json',
|
// 'Content-Type': 'application/json',
|
||||||
'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,
|
// 'x-publishable-api-key': process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY as string,
|
||||||
},
|
// },
|
||||||
})
|
// })
|
||||||
.then((res) => res.json())
|
// .then((res) => res.json())
|
||||||
.then((data) => data.products);
|
// .then((data) => data.products);
|
||||||
|
|
||||||
if (!products) {
|
// if (!products) {
|
||||||
return [];
|
// return [];
|
||||||
}
|
// }
|
||||||
// Generate static params based on product handles
|
// // Generate static params based on product handles
|
||||||
const staticParams = products.map((product) => ({
|
// const staticParams = products.map((product) => ({
|
||||||
handle: product.handle,
|
// handle: product.handle,
|
||||||
}));
|
// }));
|
||||||
return staticParams;
|
// return staticParams;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const ProductPage: FC<ProductPageProps> = ({ params }) => {
|
const ProductPage: FC<ProductPageProps> = ({ params }) => {
|
||||||
const { handle } = params; // Extract the handle from the params
|
const { handle } = params; // Extract the handle from the params
|
||||||
|
|||||||
Reference in New Issue
Block a user