Node.js Fastify with NextJS和next-i18next-res.header不是函数
我正在尝试实现Node.js Fastify with NextJS和next-i18next-res.header不是函数,node.js,next.js,i18next,fastify,Node.js,Next.js,I18next,Fastify,我正在尝试实现NextJS、fastfy和next-i18next,但当我尝试在浏览器中访问路由时,出现以下错误: TypeError:res.header不是函数 app folder\node\u modules\next-i18next\dist\commonjs\utils\redirect without cache.js:11 res.header('Cache-Control','private,无缓存,无存储,必须重新验证') 这是一个server.js文件,我从中启动Fasti
NextJS、fastfy和next-i18next
,但当我尝试在浏览器中访问路由时,出现以下错误:
TypeError:res.header不是函数
app folder\node\u modules\next-i18next\dist\commonjs\utils\redirect without cache.js:11
res.header('Cache-Control','private,无缓存,无存储,必须重新验证')
这是一个server.js
文件,我从中启动Fastify和NextJS:
const fastify = require('fastify')({ logger: { level: 'error' } })
const Next = require('next')
const nextI18NextMiddleware = require('next-i18next/middleware').default;
const nextI18next = require('./config/next-i18next');
fastify.use(nextI18NextMiddleware(nextI18next));
fastify.register((fastify, opts, next) => {
const app = Next({ dev })
const handle = app.getRequestHandler();
app.prepare().then(() => {
fastify.get('/api/places', (req, reply) => {
return reply.send({hello: 90})
})
fastify.all('/*', (req, reply) => {
return handle(req.req, reply.res).then(() => {
reply.sent = true
})
})
next();
}).catch(err => next(err));
})
。。。听
我想这是为什么。此行-fastfy.use(nextI18NextMiddleware(nextI18next))代码>,但它不在我放置它的地方,总是相同的错误。我已经了解到,在新版的fastfy
中,express中间件将是一个插件,但我使用的是“fastfy”:“^2.14.1”