Static Files on YARP Server #1712
-
Using YARP 1.10 on NET6 Minimal API. I'm trying to serve static files from
...Problem is that YARP is still intercepting the static files calls to the html files under wwwroot and trying to forward them to the default route. If I remove the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
If you want static files to attempt to serve the request before falling back to YARP, you can swap the order of app.UseStaticFiles(); // The middleware runs before routing happens => no route was found
app.UseRouting();
app.MapReverseProxy(); |
Beta Was this translation helpful? Give feedback.
UseStaticFiles
will only short-circuit the pipeline if no other route was found.If you define a route in YARP that can match the request, the static files middleware will skip the request and let YARP handle it.
If you want static files to attempt to serve the request before falling back to YARP, you can swap the order of
UseStaticFiles
andUseRouting
.