Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant set headers after they are sent #2

Open
ghost opened this issue Jun 1, 2016 · 1 comment
Open

Cant set headers after they are sent #2

ghost opened this issue Jun 1, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 1, 2016

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

@storjarn
Copy link

Interesting. What version of nodejs is running here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant