如何在 Chrome 中强制显示 504
错误?
我们有一个 Node 应用程序,偶尔会收到 504
错误,我想对 504
错误进行一些错误处理。
最佳答案
将其复制到名为 server.js 的文件中,然后运行 node server.js
。如果您访问 http://localhost:8080
您将抛出 504 错误。
var http = require('http');
var fs = require('fs');
http.createServer(function (req, res) {
console.log("Sending 504 error to client");
res.writeHead(504, {'Content-Type': 'text/plain'});
res.end();
}).listen(8080);
console.log("Server started on port 8080");
关于node.js - 如何在 Chrome 中强制出现 504 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35223685/