/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
test/e2e/api-body-parser/server.js
31 строка
769 B
Tim Neutkens
Convert test/integration to isolated tests (#93247)
11 май 2026, 14:55
Не верифицирован
11 май 2026, 14:55
8141dcf
Код
Авторство
О чём код?
const next = require('next') const express = require('express') const dev = process.env.NODE_ENV !== 'production' const dir = __dirname const port = parseInt(process.env.PORT || '3000', 10) const app = next({ dev, dir }) const handleNextRequests = app.getRequestHandler() app.prepare().then(() => { const server = express() server.use(express.json({ limit: '5mb' })) server.all('*', (req, res) => { req.fromCustomServer = true handleNextRequests(req, res) }) const httpServer = server.listen(port, (err) => { if (err) { throw err } const address = httpServer.address() const actualPort = typeof address === 'object' && address ? address.port : port console.log(`- Local: http://localhost:${actualPort}`) }) })