如何从Next.js API处理程序中进行不安全的获取?

huangapple go评论46阅读模式
英文:

How to do an unsecure fetch from Next.js api handler?

问题

我有一个 Next.js 应用程序,与一个没有 TLS 的旧微服务通信。我编写了一个 API 处理程序来使用 HTTP 查询此微服务,但当我尝试获取数据时,Next.js 阻止并显示(基本上是)"在生产环境中不允许从后端进行非安全的获取"。虽然我同意这种看法,但我仍然需要使其工作。

我尝试在我的集群中以开发模式部署了第二个 Next.js 应用程序实例,但由于与 auth0 相关的问题,这并不起作用。修改微服务非常不现实。我需要 Next.js 进行非安全获取。

英文:

I have a Next.js app that communicated with an old microservice that doesn't have TLS. I wrote an API handler to query this microservice using HTTP but when I tried to fetch Nextjs blocks it saying (basically) "no unsecured fetches from backend in prod". While I agree with this sentiment I still need this to work.

I tried deploying a second instance of my Nextjs app in dev mode to my cluster, but that didn't work because of an issue with auth0. Altering the microservice is incredibly impractical. I need Nextjs to do the unsecure fetch.

答案1

得分: 1

你可以在微服务前面引入一些反向代理,用于TLS终止。

如何实现这一点将取决于您正在使用的基础设施。

英文:

You could introduce some reverse proxy with the TLS termination in front of the microservice.

How to achieve that will depend on the infrastructure you're using.

huangapple
  • 本文由 发表于 2023年2月24日 02:57:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75549183.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定