Node.jsプログラミング言語のHTTP/HTTPSウェブサーバーのパッケージライブラリ、”express.js”において、”Cannot POST”(Cannot GET)エラーが出てしまう場合の対処方法と対策方法、原因についてです。
以下のようにres.send()
で返り値を指定していない状態であると、httpリクエストをした際にCannot POST
エラーとなります。
app.all('/configall', function (req, res, next) {
console.log('Accessing the secret section ...')
next() // pass control to the next handler
})
curl http://192.168.0.110:8111/configall
res.send()
をどこかに書いてあげればよいです。エラーがちょっとわかりにくいですね。
app.all('/configall', function (req, res, next) {
console.log('Accessing the secret section ...')
res.send("something here.")
next() // pass control to the next handler
})
curl http://192.168.0.110:8111/configall