Вот пример сервера
import next from 'next'
import express from 'express'
const nextI18NextMiddleware = require ( 'next-i18next/middleware' ).default
import nextI18next from '../i18n'
import { parse } from 'url';
const port = parseInt ( process.env.PORT || '3000', 10 )
const dev = process.env.NODE_ENV !== 'production'
const app = next ( { dev } )
const handle = app.getRequestHandler ()
app.prepare ().then ( async () => {
const server = express ()
server.use ( nextI18NextMiddleware ( nextI18next ) )
server.get ( '*', ( req, res ) => {
const parsedUrl = parse ( req.url, true )
handle ( req, res, parsedUrl )
}
)
await server.listen ( port )
console.log ( > Ready on http://localhost:${port}
)
} )