I'm currently working on deploying a Next.js
application to Firebase Functions
.
import next from 'next'
import {https} from 'firebase-functions'
const server = next({
dev: process.env.NODE_ENV !== 'production',
conf: {distDir: '.next'}
})
const nextjsHandler = server.getRequestHandler()
exports.app = https.onRequest(async (req, res) => {
await server.prepare()
return await nextjsHandler(req, res)
})
The issue I'm facing is related to Typescript error messages appearing in the code:
An error is displayed for the line
conf: {distDir: '.next'}
, showing:Type '{ distDir: string; }' is not assignable to type 'NextConfig'.
Another error is shown for the line
, specifically concerning thereturn await nextjsHandler(req, res)
res
parameter:Type error: Argument of type 'Response<any>' is not assignable to parameter of type 'ServerResponse'. Property 'req' is optional in type 'Response<any>' but required in type 'ServerResponse'.
If anyone has any insights or suggestions on how to resolve these two errors, it would be greatly appreciated. Thank you!