-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is is possible to use localStorage before rendering in browser? #7
Comments
you can add your token on url query .and then node can get token . |
我上面写的代码的意思是,在我渲染首页的时候,可以通过localStorage获取登录过的token。但是服务端渲染的话,无法在node renderToString的时候,得到locaStorage存的东西啊。 |
你可以把token 放到cookie 里面,ssr服务的根域名和 你认证权限的根域名要保持一直。 通过设置cookie 的domain属性 去控制根域名下子域名之间的cookie共享 具体参见https://developer.mozilla.org/zh-CN/docs/Web/API/Document/cookie 。 有服务端数据共享的需求用locaStorage 就不能满足了。😕 |
感谢您的建议,我现在就是用cookie没用localstorage。 |
🙂 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use token to authenticate users. It just like the following code
But localStorage is not available in node environment where inside renderToString function.
Any possible solution for this?
The text was updated successfully, but these errors were encountered: