Commit 2796c08e authored by Arunoda Susiripala's avatar Arunoda Susiripala

Fix '/' page serving issue.

It was xxxx/page//index.js
parent 6f674b8c
...@@ -68,8 +68,7 @@ export class Head extends Component { ...@@ -68,8 +68,7 @@ export class Head extends Component {
render () { render () {
const { head, styles, __NEXT_DATA__ } = this.context._documentProps const { head, styles, __NEXT_DATA__ } = this.context._documentProps
const { pathname, buildId, assetPrefix, nextExport } = __NEXT_DATA__ const { pathname, buildId, assetPrefix, nextExport } = __NEXT_DATA__
const pagePathname = getPagePathname(pathname, nextExport)
const pagePathname = nextExport ? `${pathname}/index.js` : pathname
return <head> return <head>
<link rel='preload' href={`${assetPrefix}/_next/${buildId}/page${pagePathname}`} as='script' /> <link rel='preload' href={`${assetPrefix}/_next/${buildId}/page${pagePathname}`} as='script' />
...@@ -136,8 +135,7 @@ export class NextScript extends Component { ...@@ -136,8 +135,7 @@ export class NextScript extends Component {
render () { render () {
const { staticMarkup, __NEXT_DATA__ } = this.context._documentProps const { staticMarkup, __NEXT_DATA__ } = this.context._documentProps
const { pathname, nextExport, buildId, assetPrefix } = __NEXT_DATA__ const { pathname, nextExport, buildId, assetPrefix } = __NEXT_DATA__
const pagePathname = getPagePathname(pathname, nextExport)
const pagePathname = nextExport ? `${pathname}/index.js` : pathname
return <div> return <div>
{staticMarkup ? null : <script dangerouslySetInnerHTML={{ {staticMarkup ? null : <script dangerouslySetInnerHTML={{
...@@ -158,3 +156,9 @@ export class NextScript extends Component { ...@@ -158,3 +156,9 @@ export class NextScript extends Component {
</div> </div>
} }
} }
function getPagePathname (pathname, nextExport) {
if (!nextExport) return pathname
if (pathname === '/') return '/index.js'
return `${pathname}/index.js`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment