Skip to content

Commit

Permalink
Use body-parser on /__next_reload route only
Browse files Browse the repository at this point in the history
  • Loading branch information
zchsh committed Nov 26, 2020
1 parent 072f56b commit 77e10df
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bin/next-remote-watch
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ app.prepare().then(() => {

// create an express server
const server = express()
server.use(bodyParser.json())

// special handling for mdx reload route
server.all('/__next_reload', (req, res) => {
const reloadRoute = express.Router()
reloadRoute.use(bodyParser.json())
reloadRoute.all('/', (req, res) => {
// log message if present
const msg = req.body.message
const color = req.body.color
Expand All @@ -88,6 +89,8 @@ app.prepare().then(() => {
res.end('Reload initiated')
})

server.use('/__next_reload', reloadRoute)

// handle all other routes with next.js
server.all('*', (req, res) => handle(req, res, parse(req.url, true)))

Expand Down

0 comments on commit 77e10df

Please sign in to comment.