jaredhanson / connect-flash

Flash message middleware for Connect and Express.
MIT License
1.24k stars 158 forks source link

req.flash returns empty array #46

Closed sakirma closed 4 years ago

sakirma commented 4 years ago

Hi,

I have been using connect-flash for my nodejs server which uses express 4 and it is hosted from localhost:3000. This works fine when I post with postman, but if I call this server from another server then req.flash() returns an empty array

sakirma commented 4 years ago

Sorry, I think I figured out where the problem comes from.

I use Ionic + Angular and a httppost first calls an OPTION method before calling a POST method. Which could be the reason why flash is consumed before the POST method

sakirma commented 4 years ago

Problem still persists

DanSohn commented 4 years ago

If you are console logging req.flash() before actually passing it back to the client, the console log will consume what is inside the req.flash() before you pass it on. This is because the flash middleware is only single read. So take out the console log!