getServerSideProps не работает при export next js
getServerSideProps не работает при export. Хотя локально и в versel все работает.
export const getServerSideProps = async () => {
try {
const shopsApi = new ShopsApi();
const catalogApi = new CatalogApi();
const shopsList = await shopsApi.getShopsList();
const catalogList = await catalogApi.getCatalogList();
const shops = await shopsList.json();
const catalog = await catalogList.json();
if (!shops || !catalog) {
return { notFound: true, revalidate: 1 };
}
return {
props: { shops, catalog },
revalidate: 1,
};
} catch {
return { props: { shops: null, catalog: null }, revalidate: 1 };
}
};
Получаю это при сборке export
info - Copying "static build" directory
info - No "exportPathMap" found in "D:\Hacking\projects\beer\next.config.js". Generating map from "./pages"
info - Launching 11 workers
warn - Statically exporting a Next.js application via `next export` disables API routes.
This command is meant for static-only hosts, and is not necessary to make your application static.
Pages in your application without server-side data dependencies will be automatically statically exported by `next build`, including pages powered by `getStaticProps`.
Learn more: https://nextjs.org/docs/messages/api-routes-static-export
info - Copying "public" directory
[ ] info - Exporting (0/7)
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Error for page /: pages with `getServerSideProps` can not be exported. See more info here: https://nextjs.org/docs/messages/gssp-export
at D:\Hacking\projects\beer\node_modules\next\dist\export\worker.js:227:27
at async Span.traceAsyncFn (D:\Hacking\projects\beer\node_modules\next\dist\trace\trace.js:75:20)
info - Exporting (7/7)
Error: Export encountered errors on following paths:
/
at D:\Hacking\projects\beer\node_modules\next\dist\export\index.js:498:19
at async Span.traceAsyncFn (D:\Hacking\projects\beer\node_modules\next\dist\trace\trace.js:75:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] export: `next build && next export`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] export script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\poroh\AppData\Roaming\npm-cache\_logs\2022-07-28T13_03_54_017Z-debug.log