タイトルのようなエラーが発生しました。 以下は私のコードです。誰か助けてくれますか?ノードjs - 新しいエラーをスローする( '送信後にヘッダーを設定できない');
私は 'app.get'あたり1回だけ送信したと思います。 私はindex.htmlとsplash.htmlの大文字小文字を区別したいと思います。 応答を与える前に、私は1秒間遅延させたいと思います。
app.use(delay(1000));
app.get('/index.html', function(req, res) {
var pathName = req.url;
console.log('!!!!!!!!!!!');
console.log(pathName);
fs.readFile(__dirname + '/views/index.html', function(error, data) {
console.log(__dirname);
if(error){
console.log(error);
} else {
console.log("load html");
console.log(req.url);
csp.add(req, res, options);
res.render(__dirname + '/views/index.html');
res.end();
}
});
});
app.get('/splash.html', function(req, res) {
var pathName = req.url;
console.log('!!!!!!!!!!!');
console.log(pathName);
fs.readFile(__dirname + '/views/splash.html', function(error, data) {
console.log(__dirname);
if(error){
console.log(error);
} else {
console.log("load html");
console.log(req.url);
csp.add(req, res, options);
res.render(__dirname + '/views/splash.html');
res.end();
}
});
});
「app.use(delay(1000))」を削除しても同じエラーが表示されますか? – turmuka
いいえ、私は '遅延'せずにエラーになりませんでした。私は速達を使って遅れを与えたいと思います。それが問題だと思いますか? –