How to use MongoDB Stitch Auth in isomorphic or SSR app?

巧了我就是萌 提交于 2019-12-06 11:49:50

问题


Would like to use Stitch in a NextJS app (basically isomorphic react). Normally, you would be able to pass a JWT or session token in the headers of the initial request, and if the user already has a session you can immediately load all of their data and hydrate the app on the server.

With Google Firebase Auth you can even do this by passing a token in the request and collecting the user on the server side using that token.

I'm not sure how this would work with Stitch, though. Documentation says Stitch creates a token that's stored in local storage. Is there anyway to pass this to the server to use to authenticate a user on the server?

Also, the SDK for stitch isn't isomorphic. There is a server and a browser SDK. Can one only handle user sessions in the browser? That would seem to make it difficult to use for server rendered apps. Am I missing something?

来源:https://stackoverflow.com/questions/54027960/how-to-use-mongodb-stitch-auth-in-isomorphic-or-ssr-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!