Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
96369582
Commit
96369582
authored
Jan 13, 2018
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure pages bundles are served correctly
parent
95fe683c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
page-loader.js
lib/page-loader.js
+2
-6
index.js
server/index.js
+7
-4
No files found.
lib/page-loader.js
View file @
96369582
/* global window, document
, __NEXT_DATA__
*/
/* global window, document */
import
EventEmitter
from
'./EventEmitter'
const
webpackModule
=
module
...
...
@@ -69,11 +69,7 @@ export default class PageLoader {
loadScript
(
route
)
{
route
=
this
.
normalizeRoute
(
route
)
let
scriptRoute
=
route
if
(
__NEXT_DATA__
.
nextExport
)
{
scriptRoute
=
route
===
'/'
?
'/index.js'
:
`
${
route
}
.js`
}
const
scriptRoute
=
route
===
'/'
?
'/index.js'
:
`
${
route
}
.js`
const
script
=
document
.
createElement
(
'script'
)
const
url
=
`
${
this
.
assetPrefix
}
/_next/
${
encodeURIComponent
(
this
.
buildId
)}
/page
${
scriptRoute
}
`
...
...
server/index.js
View file @
96369582
...
...
@@ -194,12 +194,12 @@ export default class Server {
await
this
.
serveStatic
(
req
,
res
,
p
)
},
'/_next/:buildId/page/:path*'
:
async
(
req
,
res
,
params
)
=>
{
'/_next/:buildId/page/:path*
.js
'
:
async
(
req
,
res
,
params
)
=>
{
const
paths
=
params
.
path
||
[
''
]
// URL is asks for ${page}.js (to support loading assets from static dirs)
// But there's no .js in the actual page.
// So, we need to remove .js to get the page name.
const
page
=
`/
${
paths
.
join
(
'/'
)}
`
.
replace
(
'.js'
,
''
)
const
page
=
`/
${
paths
.
join
(
'/'
)}
`
if
(
!
this
.
handleBuildId
(
params
.
buildId
,
res
))
{
const
error
=
new
Error
(
'INVALID_BUILD_ID'
)
...
...
@@ -222,8 +222,11 @@ export default class Server {
}
}
const
p
=
join
(
this
.
dir
,
this
.
dist
,
'bundles'
,
'pages'
,
paths
.
join
(
'/'
))
await
this
.
serveStatic
(
req
,
res
,
p
)
let
p
=
join
(
this
.
dir
,
this
.
dist
,
'bundles'
,
'pages'
,
paths
.
join
(
'/'
))
if
(
!
fs
.
existsSync
(
`
${
p
}
.js`
))
{
p
=
join
(
p
,
'index'
)
// It's possible to have index.js in a subfolder
}
await
this
.
serveStatic
(
req
,
res
,
`
${
p
}
.js`
)
},
// It's very important keep this route's param optional.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment