0
プラットフォーム:node.js + expressおよびrequest modules(beginner)。node.js - レスポンスヘッダーを変更する方法
こんにちは、単純にrouter.getの後にリクエストがあり、外部サーバーから取得したヘッダーを変更して、特定のデータを要求したユーザーに送信します。
router.get('/', function(req, res){
var someUserRequest = request('http://google.com', function(error, resp, body){
if (error){
console.log(error);
}
console.log(resp.headers); //lets assume that there is 'x-content-type-options' that I don't want for example
}
req.pipe(someUserRequest).on('response', function(response){
delete response.headers['x-content-type-options'];
console.log(response.headers); // everything looks fine here - no 'x-content-type-options'
}).pipe(res);
});
module.exports = router;
したがって、 'x-content-type-options'はありません。しかし、これをクロム開発ツール(ネットワーク)でチェックすると、すべての履歴/キャッシュをクリアしても、「x-content-type-options:nosniff」がはっきりと確認できます。
なぜ機能しないのですか?誰かがエラーがどこにあるのか教えていただけますか?