File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { RouteParamsMetadata } from '@nestjs/common/decorators';
1616import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum' ;
1717import { Controller , Transform } from '@nestjs/common/interfaces' ;
1818import {
19+ isEmpty ,
1920 isFunction ,
2021 isString ,
2122 isUndefined ,
@@ -248,15 +249,18 @@ export class RouterExecutionContext {
248249 ) {
249250 const renderTemplate = this . reflectRenderTemplate ( callback ) ;
250251 const responseHeaders = this . reflectResponseHeaders ( callback ) ;
252+ const hasCustomHeaders = ! isEmpty ( responseHeaders ) ;
251253
252254 if ( renderTemplate ) {
253255 return async ( result , res ) => {
254- this . responseController . setHeaders ( res , responseHeaders ) ;
256+ hasCustomHeaders &&
257+ this . responseController . setHeaders ( res , responseHeaders ) ;
255258 await this . responseController . render ( result , res , renderTemplate ) ;
256259 } ;
257260 }
258261 return async ( result , res ) => {
259- this . responseController . setHeaders ( res , responseHeaders ) ;
262+ hasCustomHeaders &&
263+ this . responseController . setHeaders ( res , responseHeaders ) ;
260264
261265 ! isResponseHandled &&
262266 ( await this . responseController . apply ( result , res , httpStatusCode ) ) ;
You can’t perform that action at this time.
0 commit comments