I am using YARP to migrate a legacy Web Forms application to Blazor (8.0) one module at a time (Strangler Fig pattern).
My new Blazor application is running on port 5017. The legacy app is located on port 15209.
All the references have been configured in the appsetting.json file.
appsettings.json
{
"ReverseProxy": {
"Routes": {
"System-Route": {
"ClusterId": "LegacySite",
"Match": {
"Path": "/System/{**catch-all}"
}
},
"CSS-Route": {
"ClusterId": "LegacySite",
"Match": {
"Path": "/CSS/{**catch-all}"
}
},
"JS-Route": {
"ClusterId": "LegacySite",
"Match": {
"Path": "/JS/{**catch-all}"
}
}
},
"Clusters": {
"LegacySite": {
"Destinations": {
"App": {
"Address": "http://localhost:15209/"
}
}
}
}
}
}
And I have updated Routes.razor to provide feedback when a route was not found.
Routes.razor
<Router AppAssembly="typeof(Program).Assembly" OnNavigateAsync="@OnNavigationAsync">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
<NotFound>
<LayoutView Layout="typeof(MainLayout)" >
@($"The route, {path} was not found.")
</LayoutView>
</NotFound>
</Router>
@code{
string path { get; set; } = "";
void OnNavigationAsync(NavigationContext args)
{
this.path = args.Path;
}
}
I have confirmed that the configuration appears to be working as static resource files from the legacy site such as CSS and JS are all successfully referenced and applied.
The Problem The problem comes when I click on a link from the Blazor site (:5017) that needs to be forwarded to its Web Forms counterpart in the legacy site (:15209). When I attempt to forward the request the Router component in Routes.razor registers it as "NotFound". Yet when I refresh the page (Ctrl+R), the page loads as expected.
When I click on the "System" menuitem I can see that the "Path" appears to be correct, and correctly defined in the configuration, yet I get a NOT FOUND error.
When I refresh the browser using the refresh button (Ctrl+R) the form hosted on the legacy Web Forms, loads as expected (also happens on a hot-reload).
This is my first time working with YARP so perhaps I missing or overlooking something?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745070344a4609505.html
评论列表(0条)