简体   繁体   English

Angular 9 SSR 刷新/重新加载

[英]Angular 9 SSR refresh/reload

I have the following problem with Angular and SSR .我对AngularSSR有以下问题。 I use angular 9 .我使用角 9 Everything works fine but when I click F5 the first thing which I see is the login page of my application and after that I see the page I'm on.一切正常,但是当我单击F5时,我看到的第一件事是我的应用程序的登录页面,然后我看到了我所在的页面。 I built the application with angular 8 and everything worked fine.我用angular 8构建了应用程序,一切正常。 Now I decided to migrate to the next version.现在我决定迁移到下一个版本。

Any suggestion?有什么建议吗?

这是您的令牌的问题,您可能使用 localstorage 来存储令牌,而您的后端将无法从中获取令牌,因此它首先显示登录屏幕,然后在有角度的一侧提供实际页面,您需要使用 cookie 而不是 localstorage 来解决这个问题,或者更容易使用加载器,直到平台浏览器检测完成,其余的事情将以相同的方式工作。

I have the same issue too.我也有同样的问题。

So, I try to remove and add an angular universal again.所以,我尝试再次删除并添加一个角度通用。 It shows that some structures has changed.它表明某些结构发生了变化。
https://v9.angular.io/guide/universal https://v9.angular.io/guide/universal

And also, I'm not sure about how Ivy work with SSR so I disabled it by adding an option in tsconfig.app.json followed this https://v9.angular.io/guide/ivy而且,我不确定 Ivy 如何与 SSR 一起工作,所以我通过在 tsconfig.app.json 中添加一个选项来禁用它,然后是https://v9.angular.io/guide/ivy

And then it works.然后它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM