PPiing / PPoong

for PingPong SPA
MIT License
7 stars 1 forks source link

:bug: backend response header 불필요한 정보 노출 #12

Open muingY opened 2 years ago

muingY commented 2 years ago

Symptom

HTTP/1.1 200 OK
X-Powered-By: -------
Content-Type: text/html; charset=utf-8
Content-Length: 12
ETag: W/"c-----------------------------------------"
Date: Thu, 21 Apr 2022 15:17:11 GMT
Connection: close

Hello World!

Environment (OS / Browser)

How To Solve

fix | backend/src/main.ts

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  // Patch code start.
  app.getHttpAdapter().getInstance().set('etag', false);
  app.getHttpAdapter().getInstance().set('x-powered-by', false);
  // Patch code end.

  await app.listen(3000);
}

Patch code를 통해 response 해더에 원하는 정보를 제외시킬 수 있다. 결과는 다음과 같다.

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 12
Date: Thu, 21 Apr 2022 15:24:07 GMT
Connection: close

Hello World!

불필요한 정보 제공에 대한 문제는 해결되나 etag에 대한 정보를 제공하지 않을 경우 같은 화면에서 새로고침할 경우 중복되는 body를 계속 통신한다. 백앤드 특성상 영향이 없을 것이라고 생각한다.