Skip to content

Static Files on YARP Server #1712

Answered by MihaZupan
mattsmithdev asked this question in Q&A
Discussion options

You must be logged in to vote

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 and UseRouting.

app.UseStaticFiles(); // The middleware runs before routing happens => no route was found

app.UseRouting();

app.MapReverseProxy();

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mattsmithdev
Comment options

@samsp-msft
Comment options

@keshavkaul
Comment options

Answer selected by mattsmithdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants