반응형
ExpressJS에서 X-Powered-By를 제거하는 방법
보안을 위해 X-Powered-By를 제거하고 고속으로 대역폭을 저장합니다.JS(노드.js).어떻게 합니까?필터(앱.use)일 수 있습니까?
app.use(function(req,res,next_cb){ /* remove X-Powered-By header */ next_cb(); }
제거하지 말고 Express에 요청하여 처음부터 생성하지 마십시오.
https://stackoverflow.com/a/12484642/506073
이동app.js바로 다음과 같습니다.
var app = express();
추가:
app.disable('x-powered-by');
더 나은 방법은 다음과 같습니다.
app.disable('x-powered-by');
다음과 같이 미들웨어를 만들어 헤더를 제거할 수도 있습니다.
app.use(function (req, res, next) {
res.removeHeader("X-Powered-By");
next();
});
헤더를 제거하는 방법에 대한 자세한 내용은 다음을 참조하십시오.
http://nodejs.org/api/http.html#http_response_removeheader_name
미들웨어 스니펫 출처:X-Powered-By 헤더를 제거할 수 없습니다.익스프레스
function customHeaders( req, res, next ){
// Switch off the default 'X-Powered-By: Express' header
app.disable( 'x-powered-by' );
// OR set your own header here
res.setHeader( 'X-Powered-By', 'Awesome App v0.0.1' );
// .. other headers here
next();
}
app.use( customHeaders );
// ... now your code goes here
언급URL : https://stackoverflow.com/questions/10717685/how-to-remove-x-powered-by-in-expressjs
반응형
'programing' 카테고리의 다른 글
| 패턴과 일치하는 폴더에 파일 이름 나열(파일 내용 제외) (0) | 2023.07.31 |
|---|---|
| 서버 태그의 형식이 올바르지 않습니다. 오류 (0) | 2023.07.31 |
| Spring MVC는 여러 사용자를 어떻게 처리합니까? (0) | 2023.07.31 |
| Python에서 범위 차단 (0) | 2023.07.31 |
| Laravel 소프트 삭제 가능한 MySQL/MariaDB 파티션(삭제된_at IS NULL 대 datetime 값) (0) | 2023.07.31 |