如何在 Next.js 中向 getServerSideProps 添加标头
我想在 Next.js 中使用 getServersideProps 传递 JWT 访问令牌。令牌存储在本地存储中。 有什么办法可以做到吗?
想要向 Next.js 中的 getServerSideProps 添加标头
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
getServerSideProps
接受context
参数,其中包含用于访问IncomingMessage
的键(req
) 和ServerResponse
(res
) 对象。如果要添加标头,可以使用响应对象的setHeader
方法。getServerSideProps
accepts acontext
parameter which includes keys for accessing theIncomingMessage
(req
) andServerResponse
(res
) objects. If you want to add a header, you can use the response object'ssetHeader
method.