英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论