/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
test/development/ondemand/server.js
36 строк
767 B
Tim Neutkens
Convert test/integration to isolated tests (#93247)
11 май 2026, 14:55
Не верифицирован
11 май 2026, 14:55
8141dcf
Код
Авторство
О чём код?
const http = require('http') const next = require('next') const getPort = require('get-port') const { assetPrefix } = require('./next.config') const dev = process.env.NODE_ENV !== 'production' const dir = __dirname function rewriteAssetPrefix(req) { if (assetPrefix) { req.url = req.url.replace(`${assetPrefix}/`, '') } } const app = next({ dev, dir }) const nextReqHandler = app.getRequestHandler() async function main() { await app.prepare() const port = await getPort() const server = new http.Server((req, res) => { rewriteAssetPrefix(req) return nextReqHandler(req, res) }) server.listen(port, () => { console.log(`- Local: http://localhost:${port}`) }) } main().catch((err) => { console.error(err) process.exit(1) })