在nextjs和后端api之间使用JWT cookie
我有一个nodejs Express后端api,它是通过 JWT + cookie 的身份验证方法实现的。 现在我想将它与另一个域上的 nextjs 前端连接。我知道这对于代理是可行的,但是由于 nextjs 应用程序在构建时需要 api 内容,因此如何才能通过代理接收 api 数据,而前端应用程序(包含后端域的代理)则不能还安装完整吗?
如果你知道一个例子,我很乐意向我展示。
I have a nodejs express back-end api which is implemented with authentication approach of JWT + cookie .
Now I want to connect it with a nextjs front-end which is on another domain . I know this is viable with proxy, but since nextjs app needs the api content on the build time, how is it possible to receive the api data through proxy while the fron-end app ( which contains proxy to back-end domain ) is not still installed completely ?
I case you know an example I would appreciate to show me .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这个包正是您所需要的: next-http-proxy-middleware
https ://www.npmjs.com/package/next-http-proxy-middleware
I believe that this package is what you need : next-http-proxy-middleware
https://www.npmjs.com/package/next-http-proxy-middleware