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
718a36e1
Commit
718a36e1
authored
Jul 16, 2019
by
Lukáš Huvar
Committed by
Tim Neutkens
Jul 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix build for API routes conflict pages (#7992)
* Fixes #7991 * Fix tests
parent
571eb981
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
2 deletions
+13
-2
entries.ts
packages/next/build/entries.ts
+1
-1
next-serverless-loader.ts
...ages/next/build/webpack/loaders/next-serverless-loader.ts
+1
-1
api-conflict.js
test/integration/api-support/pages/api-conflict.js
+1
-0
index.test.js
test/integration/api-support/test/index.test.js
+10
-0
No files found.
packages/next/build/entries.ts
View file @
718a36e1
...
...
@@ -68,7 +68,7 @@ export function createEntrypoints(
Object
.
keys
(
pages
).
forEach
(
page
=>
{
const
absolutePagePath
=
pages
[
page
]
const
bundleFile
=
page
===
'/'
?
'/index.js'
:
`
${
page
}
.js`
const
isApiRoute
=
bundleFile
.
startsWith
(
'/api'
)
const
isApiRoute
=
bundleFile
.
startsWith
(
'/api
/
'
)
const
bundlePath
=
join
(
'static'
,
buildId
,
'pages'
,
bundleFile
)
...
...
packages/next/build/webpack/loaders/next-serverless-loader.ts
View file @
718a36e1
...
...
@@ -39,7 +39,7 @@ const nextServerlessLoader: loader.Loader = function() {
'/'
)
if
(
page
.
startsWith
(
'/api'
))
{
if
(
page
.
startsWith
(
'/api
/
'
))
{
return
`
${
isDynamicRoute
(
page
)
...
...
test/integration/api-support/pages/api-conflict.js
0 → 100644
View file @
718a36e1
export
default
()
=>
<
div
>
API
-
conflict
<
/div
>
test/integration/api-support/test/index.test.js
View file @
718a36e1
...
...
@@ -9,6 +9,7 @@ import {
fetchViaHTTP
,
renderViaHTTP
,
nextBuild
,
nextStart
,
File
}
from
'next-test-utils'
import
json
from
'../big.json'
...
...
@@ -35,6 +36,15 @@ function runTests (serverless = false) {
expect
(
status
).
toEqual
(
404
)
})
it
(
'should not conflict with /api routes'
,
async
()
=>
{
const
port
=
await
findPort
()
await
nextBuild
(
appDir
)
const
app
=
await
nextStart
(
appDir
,
port
)
const
res
=
await
fetchViaHTTP
(
port
,
'/api-conflict'
)
expect
(
res
.
status
).
not
.
toEqual
(
404
)
killApp
(
app
)
})
it
(
'should return custom error'
,
async
()
=>
{
const
data
=
await
fetchViaHTTP
(
appPort
,
'/api/error'
,
null
,
{})
const
json
=
await
data
.
json
()
...
...
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