I'm trying to deploy the next.js app to firebase hosting but I get error mentioned in the title:
error: Could not find a production build in the '/workspace/' directory
I build my app locally using next build command.
The production version is built to .next folder which is firebase deployment folder.
My server looks like this:
const { https } = require('firebase-functions');
const { default: next } = require('next');
const server = next({
dev: process.env.NODE_ENV !== 'production',
conf: {distDir: '/'}
})
const nextjsHandler = server.getRequestHandler()
exports.nextServer = https.onRequest(async (req, res) => {
await server.prepare()
return await nextjsHandler(req, res)
})
For testing I deploy static html project and everything is ok.
But with next ssr app it wont start, in firebase function console I get info:
nextServer Error: Could not find a production build in the '/workspace/' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id at Server.readBuildId (/workspace/node_modules/next/dist/server/next-server.js:1872:23) at new Server (/workspace/node_modules/next/dist/server/next-server.js:104:29) at NextServer.createServer (/workspace/node_modules/next/dist/server/next.js:111:16) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async /workspace/node_modules/next/dist/server/next.js:123:31 at async NextServer.prepare (/workspace/node_modules/next/dist/server/next.js:98:24) at async /workspace/index.js:12:3
I tried to change conf: {distDir: '/'} for example to conf: {distDir: '/.next'}
but then I get error:
Could not find a production build in the '/workspace/.next' directory.