【发布时间】:2020-03-26 12:32:24
【问题描述】:
我有一个在 PaaS 中托管的带有 .NET Core 后端的 React 应用程序。我正在尝试 URL 将请求重写到另一个应用程序,但我无法将其重写到另一个域。例如:
我的应用程序位于:
https://example.com
我的 JS 向 /api/orders 发出 GET 请求,然后我有一个请求:
https://example.com/api/orders
我正在尝试使用 URL Rewrite 中间件将此请求重写为:
https://another-example.com/api/orders
我已经尝试过使用这个:
RewriteOptions rewriteOptions = new RewriteOptions()
.AddRewrite(@"^api/orders/(.+)", "https://another-example/api/orders/$1", skipRemainingRules: true);
还创建了一个实现IRule 接口的类,但没有一个工作。这些仅适用于相同的域重写。有没有办法做到这一点?
【问题讨论】:
-
您有机会实现您所寻找的吗?
-
@PhaniKrishnaVemireddy 我最终实现了自己的中间件,类似于 Andrea Chiarelli 在这里解释的 auth0.com/blog/building-a-reverse-proxy-in-dot-net-core
标签: c# asp.net-core url-rewriting