In der HTTP/HTTPS-Webserver-Paketbibliothek “express.js” für die Node.js-Programmiersprache behandelt dieser Artikel Gegenmaßnahmen, Präventionsmethoden und Ursachen, wenn “Cannot POST” (Cannot GET) Fehler auftreten.
Wenn Sie keinen Rückgabewert mit res.send() angeben, wie unten gezeigt, erhalten Sie einen Cannot POST-Fehler beim Ausführen einer HTTP-Anfrage.
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
Sie sollten res.send() irgendwo schreiben. Der Fehler ist etwas unklar.
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
Auf diese Weise, wenn Sie res.send() schreiben, wird der Cannot POST-Fehler nicht mehr auftreten.