-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into fix/incoming-message-cookies-type
- Loading branch information
Showing
26 changed files
with
301 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Cancel | ||
on: | ||
pull_request_target: | ||
types: | ||
- edited | ||
- synchronize | ||
|
||
jobs: | ||
cancel: | ||
name: 'Cancel Previous Runs' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 2 | ||
steps: | ||
- uses: styfle/[email protected] | ||
with: | ||
workflow_id: 444921, 444987 | ||
access_token: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Could not find a production build | ||
|
||
#### Why This Error Occurred | ||
|
||
When running `next export` a production build is needed. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
- Run `next build` to create a production build before running `next export`. | ||
- If your intention was to run the development server run `next dev` instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Could not find a production build | ||
|
||
#### Why This Error Occurred | ||
|
||
When running `next start` or a custom server in production mode a production build is needed. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
- Run `next build` to create a production build before booting up the production server. | ||
- If your intention was to run the development server run `next dev` instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default ({ method, body }, res) => { | ||
if (method === 'POST') { | ||
res.status(200).json(body) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const next = require('next') | ||
const bodyParser = require('body-parser') | ||
const express = require('express') | ||
|
||
const dev = process.env.NODE_ENV !== 'production' | ||
const dir = __dirname | ||
const port = process.env.PORT || 3000 | ||
|
||
const app = next({ dev, dir }) | ||
const handleNextRequests = app.getRequestHandler() | ||
|
||
app.prepare().then(() => { | ||
const server = express() | ||
|
||
server.use(bodyParser.json({ limit: '5mb' })) | ||
|
||
server.all('*', (req, res) => { | ||
handleNextRequests(req, res) | ||
}) | ||
|
||
server.listen(port, (err) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
console.log(`> Ready on http://localhost:${port}`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* eslint-env jest */ | ||
|
||
import { join } from 'path' | ||
import { | ||
killApp, | ||
findPort, | ||
launchApp, | ||
fetchViaHTTP, | ||
initNextServerScript, | ||
} from 'next-test-utils' | ||
import clone from 'clone' | ||
import getPort from 'get-port' | ||
|
||
jest.setTimeout(1000 * 60 * 2) | ||
const appDir = join(__dirname, '../') | ||
let appPort | ||
|
||
let app | ||
let server | ||
jest.setTimeout(1000 * 60 * 2) | ||
|
||
const context = {} | ||
|
||
function runTests() { | ||
it('should parse JSON body', async () => { | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort, {}) | ||
const data = await makeRequest() | ||
expect(data).toEqual([{ title: 'Nextjs' }]) | ||
killApp(app) | ||
}) | ||
|
||
it('should not throw if request body is already parsed in custom middleware', async () => { | ||
await startServer() | ||
const data = await makeRequest() | ||
expect(data).toEqual([{ title: 'Nextjs' }]) | ||
killApp(server) | ||
}) | ||
} | ||
|
||
async function makeRequest() { | ||
const data = await fetchViaHTTP(appPort, '/api', null, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json; charset=utf-8', | ||
}, | ||
body: JSON.stringify([{ title: 'Nextjs' }]), | ||
}).then((res) => res.ok && res.json()) | ||
|
||
return data | ||
} | ||
|
||
const startServer = async (optEnv = {}, opts) => { | ||
const scriptPath = join(appDir, 'server.js') | ||
context.appPort = appPort = await getPort() | ||
const env = Object.assign( | ||
{}, | ||
clone(process.env), | ||
{ PORT: `${appPort}` }, | ||
optEnv | ||
) | ||
|
||
server = await initNextServerScript( | ||
scriptPath, | ||
/ready on/i, | ||
env, | ||
/ReferenceError: options is not defined/, | ||
opts | ||
) | ||
} | ||
|
||
runTests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.