Skip to content

Cant set headers after they are sent #2

Description

Hi,

I am running your code on cloud foundry. Whenever I try to enter the secure page without being authenticated, I get the following error

ERR Error: Can't set headers after they are sent.
ERR at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:335:11)
ERR at ServerResponse.header (/home/vcap/app/node_modules/express/lib/response.js:718:10)
ERR at ServerResponse.send (/home/vcap/app/node_modules/express/lib/response.js:163:12)
ERR at /home/vcap/app/routes/secure.js:12:30

Line causing the problem is:

next(res.sendStatus(403).send('Forbidden'));

It seems to be because the header has already been sent, and you are trying to set the status code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions