1
0
mirror of synced 2025-12-21 10:57:10 -05:00
Files
docs/middleware/next.js
Mike Surowiec 06d8f81401 Two-pane Experiment (#21092)
* pull changes from docs-playground

* cleanup, add callout banner

* cleanup linting and test fixes

* add discussion link

Co-authored-by: James M. Greene <JamesMGreene@github.com>
2021-08-26 14:19:40 -04:00

22 lines
601 B
JavaScript

import next from 'next'
const { NODE_ENV } = process.env
const isDevelopment = NODE_ENV === 'development'
export const nextApp = next({ dev: isDevelopment })
export const nextHandleRequest = nextApp.getRequestHandler()
await nextApp.prepare()
function renderPageWithNext(req, res, next) {
const isNextDataRequest = req.path.startsWith('/_next') && !req.path.startsWith('/_next/data')
// /playground is for playground static assets
if (isNextDataRequest || req.path.startsWith('/playground')) {
return nextHandleRequest(req, res)
}
return next()
}
export default renderPageWithNext