mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
use native http instead of micro (#5706)
This commit is contained in:
parent
e1f6f34f86
commit
9547e77820
|
@ -55,7 +55,6 @@
|
|||
"jest-cli": "23.6.0",
|
||||
"lerna": "^3.4.0",
|
||||
"lint-staged": "4.2.3",
|
||||
"micro": "9.1.0",
|
||||
"mkdirp": "0.5.1",
|
||||
"node-fetch": "1.7.3",
|
||||
"node-notifier": "5.1.2",
|
||||
|
|
|
@ -899,14 +899,14 @@ Here's an example usage of it:
|
|||
|
||||
```js
|
||||
const next = require('next')
|
||||
const micro = require('micro')
|
||||
const http = require('http')
|
||||
|
||||
const dev = process.env.NODE_ENV !== 'production'
|
||||
const app = next({ dev })
|
||||
const handleNextRequests = app.getRequestHandler()
|
||||
|
||||
app.prepare().then(() => {
|
||||
const server = micro((req, res) => {
|
||||
const server = new http.Server((req, res) => {
|
||||
// Add assetPrefix support based on the hostname
|
||||
if (req.headers.host === 'my-app.com') {
|
||||
app.setAssetPrefix('http://cdn.com/myapp')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const micro = require('micro')
|
||||
const http = require('http')
|
||||
const next = require('next')
|
||||
|
||||
const dev = process.env.NODE_ENV !== 'production'
|
||||
|
@ -9,7 +9,7 @@ const app = next({ dev, dir })
|
|||
const handleNextRequests = app.getRequestHandler()
|
||||
|
||||
app.prepare().then(() => {
|
||||
const server = micro((req, res) => {
|
||||
const server = new http.Server((req, res) => {
|
||||
if (/setAssetPrefix/.test(req.url)) {
|
||||
app.setAssetPrefix(`http://127.0.0.1:${port}`)
|
||||
} else if (/setEmptyAssetPrefix/.test(req.url)) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const micro = require('micro')
|
||||
const http = require('http')
|
||||
const next = require('next')
|
||||
|
||||
const dev = process.env.NODE_ENV !== 'production'
|
||||
|
@ -9,7 +9,7 @@ const app = next({ dev, dir })
|
|||
const handleNextRequests = app.getRequestHandler()
|
||||
|
||||
app.prepare().then(() => {
|
||||
const server = micro((req, res) => {
|
||||
const server = new http.Server((req, res) => {
|
||||
if (/setAssetPrefix/.test(req.url)) {
|
||||
app.setAssetPrefix(`http://127.0.0.1:${port}`)
|
||||
} else if (/setEmptyAssetPrefix/.test(req.url)) {
|
||||
|
|
Loading…
Reference in a new issue