| 8 | await nextApp.prepare() |
| 9 | |
| 10 | function renderPageWithNext(req, res, next) { |
| 11 | // We currently don't use next/image for any images. |
| 12 | // We don't even have `sharp` installed. |
| 13 | // This could change in the future but right now can just 404 on these |
| 14 | // so we don't have to deal with any other errors. |
| 15 | if (req.path.startsWith('/_next/image')) { |
| 16 | return next(404) |
| 17 | } |
| 18 | |
| 19 | const isNextDataRequest = req.path.startsWith('/_next') && !req.path.startsWith('/_next/data') |
| 20 | |
| 21 | if (isNextDataRequest) { |
| 22 | return nextHandleRequest(req, res) |
| 23 | } |
| 24 | |
| 25 | return next() |
| 26 | } |
| 27 | |
| 28 | export default renderPageWithNext |