Skip to content

Response headers doesn't work #407

Open
@joain946

Description

@joain946

I'm submitting a...


[x] Bug report

Current behavior

Response headers are not sent back to the client.
The example below returns this response:


HTTP/1.1 200 OK
Date: Tue, 10 Nov 2020 12:39:58 GMT
Server: Kestrel
Content-Length: 12

Hello World!

Expected behavior

All response headers should be returned to the client.
From the example below the "Content-Type" and "MyHeader" header should have been returned from the REST api.

Minimal reproduction of the problem with instructions

Using this instruction:
https://trilon.io/blog/deploy-nestjs-azure-functions
Then adding two @Header() decorators to the api:


import { Controller, Get, Header } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @Header("Content-Type", "text/plain")
  @Header("MyHeader", "MyHeaderValue")
  getHello(): string {
    return this.appService.getHello();
  }
}

Environment


Nest version: 7.4.4
 
For Tooling issues:
- Node version: v12.18.0
- Platform:  Windows

Workaround

It seems like the writeHead(...) method is never called.
Triggering this method from IDE or through code (in an interceptor) solves the issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions