Angular登录成功后刷新页面重定向至登录页问题
NestJS + MongoDB 认证后刷新页面重定向登录,Teachers路由404问题
我用NestJS搭建后端,结合MongoDB实现认证功能,注册和登录流程正常,但登录成功后刷新页面会重定向到login路由。
登录成功后的Cookie信息
Authentication expires "2022-07-29T09:48:43.000Z" httpOnly true path "/" value "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2MmUyOTUzMmQwZGVmYjA5NGFiMTU0YzMiLCJpYXQiOjE2NTkwODQ1MjMsImV4cCI6MTY1OTA4ODEyM30.QfMS3hI-Jpyj9CCSPgQfxHplTewSX95rl7lLTVSm-pg"
登录请求详情
POST http://localhost:4200/api/auth/login Status 201 Created VersionHTTP/1.1 Transferred568 B (62 B size) Referrer Policystrict-origin-when-cross-origin Request PriorityHighest
登录响应内容
_id "62e29532d0defb094ab154c3" email "test@gmail.com"
相关代码文件
- app.module.ts
- auth.guard.ts
- app.component.ts
- auth.service.ts
- front-routing.module.ts
- proxy.conf.json
- angular.json
(代码内容保留原格式)
额外问题:Teachers路由访问异常
打开teachers路由时出现以下错误并被重定向到登录页:
XHR GET http://localhost:4200/api/auth/login [HTTP/1.1 404 未找到 4ms] 请先登录
内容的提问来源于stack exchange,提问作者DolDurma
相关产品推荐
相关产品推荐

