express icon indicating copy to clipboard operation
express copied to clipboard

Error: Can't set headers after they are sent.

Open gahula opened this issue 13 years ago • 2 comments

The error occurs when i render my login page and i try to go to a page(without login in) and that page redirects me back to the login page.

So..

render (login page) >> redirect (settings page) >> render (login page). Is there a way around this?

gahula avatar Jan 06 '13 05:01 gahula

It seems adding a return after the redirect solved the problem.

if(req.xhr) { res.send(200,{redirect: '/signin'}); return; } else { res.redirect('/signin'); return; }

gahula avatar Jan 07 '13 05:01 gahula

yeah you just can't respond twice

tj avatar Jan 09 '13 20:01 tj