I had the same error in my own version, so I downloaded the files from lesson 11 fresh off of GitHub. Both return the same error when trying to build the app:
$ npm run build
dojo-helpdesk@0.1.0 build
next build
info Creating an optimized production build
info Compiled successfully
info Linting and checking validity of types
info Collecting page data ...TypeError: fetch failed
at node:internal/deps/undici/undici:12618:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: AggregateError [ECONNREFUSED]:
at internalConnectMultiple (node:net:1116:18)
at afterConnectMultiple (node:net:1683:7)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'ECONNREFUSED',
[errors]: [ [Error], [Error] ]
}
}
Build error occurred
Error: Failed to collect page data for /tickets/[id]
at C:\Users\chris\Documents\GitHub\Netninja-Next13-Masterclass\nextjs-masterclass-lesson-11\node_modules\next\dist\build\utils.js:1158:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}
I had the same problem and managed to solve it. Turns out JSON Server needs to be running when you build, otherwise Next can't fetch from the end point (because it isn't there).
I had the same error in my own version, so I downloaded the files from lesson 11 fresh off of GitHub. Both return the same error when trying to build the app:
$ npm run build