1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Resolve the path in renderJSON before serving. (#599)

This commit is contained in:
Arunoda Susiripala 2017-01-01 15:37:56 +05:30 committed by Naoyuki Kanezawa
parent 81a67581ed
commit 33fa931207

View file

@ -5,6 +5,7 @@ import fs from 'mz/fs'
import send from 'send'
import accepts from 'accepts'
import requireModule from './require'
import resolvePath from './resolve'
import readPage from './read-page'
import { Router } from '../lib/router'
import Head, { defaultHead } from '../lib/head'
@ -97,7 +98,7 @@ async function doRender (req, res, pathname, query, {
}
export async function renderJSON (req, res, page, { dir = process.cwd() } = {}) {
const pagePath = join(dir, '.next', 'bundles', 'pages', `${page}.json`)
const pagePath = await resolvePath(join(dir, '.next', 'bundles', 'pages', page))
return serveStaticWithGzip(req, res, pagePath)
}