文章詳情頁
node.js - express router中無法獲取session
瀏覽:145日期:2024-07-16 10:05:13
問題描述
我在app.js中直接使用 app.post();可以獲取session。但是我在router中使用 router.post();就獲取不到session,是怎么回事?求大神指點(diǎn)
如圖
顯示 seession 獲取不到
問題解答
回答1:是不是順序的問題,session中間件需要在所有router之前
回答2:感覺你第二個router沒有和app關(guān)聯(lián)起來,所以你后面那個沒有進(jìn)入session中間件,導(dǎo)致session取不到。
回答3:app.use(’/xxx’, router);
是不是少了這個
相關(guān)文章:
1. android - weex 項目createInstanceReferenceError: Vue is not defined2. javascript - 如圖,百度首頁,查看源代碼為什么什么都沒有?3. 網(wǎng)頁爬蟲 - python requests爬蟲,如何post payload4. npm鏡像站全新上線5. angular.js - 求問大神?angularjs加載外部的html模板。有閃動如何解決6. html - 關(guān)于CSS實(shí)現(xiàn)border的0.5px設(shè)置?7. PHPExcel表格導(dǎo)入數(shù)據(jù)庫怎么導(dǎo)入8. android - 哪位大神知道java后臺的api接口的對象傳到前端后輸入日期報錯,是什么情況?求大神指點(diǎn)9. pdo 寫入到數(shù)據(jù)庫的內(nèi)容為中文的時候?qū)懭雭y碼10. PHP類封裝的插入數(shù)據(jù),總是插入不成功,返回false;
排行榜

熱門標(biāo)簽