Hi, I’ve modified a page in my NextJS app to use getServerSideProps():
export async function getServerSideProps() {
const helpers = createServerSideHelpers({
router: databaseRouter,
ctx: {},
transformer: SuperJSON,
});
await helpers.getAllOrganizations.prefetch();
await helpers.getAllContacts.prefetch();
return {
props: {
trpcState: helpers.dehydrate(),
},
};
}
npm run build
completes without issues locally but when I run fly deploy
I get the error
#0 1.826 - info Linting and checking validity of types...
#0 13.20 - info Creating an optimized production build...
#0 26.54 - info Compiled successfully
#0 26.54 - info Collecting page data...
#0 27.13 TypeError [ERR_INVALID_URL]: Invalid URL
#0 27.13 at new NodeError (node:internal/errors:400:5)
#0 27.13 at URL.onParseError (node:internal/url:565:9)
#0 27.13 at new URL (node:internal/url:645:5)
#0 27.13 at parseUrl (file:///app/node_modules/postgres/src/index.js:491:18)
#0 27.13 at parseOptions (file:///app/node_modules/postgres/src/index.js:389:30)
#0 27.13 at Postgres (file:///app/node_modules/postgres/src/index.js:50:19)
#0 27.13 at /app/.next/server/pages/db.js:2048:68 {
#0 27.13 input: '',
#0 27.13 code: 'ERR_INVALID_URL'
#0 27.13 }
#0 27.14
#0 27.14 > Build error occurred
#0 27.14 Error: Failed to collect page data for /db
#0 27.14 at /app/node_modules/next/dist/build/utils.js:1158:15 {
#0 27.14 type: 'Error'
#0 27.14 }
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 1
To fix this error, are there additional configurations I need to make when calling getServerSideProps() in a project deployed to fly.io? Thank you.