Skip to content

Proxy handle static content #472

Answered by Tratcher
tbonham asked this question in Q&A
Discussion options

You must be logged in to vote

The main question is how you identify which paths are for static files, and what priority you give them. The standard StaticFiles middleware should work with YARP. If all paths should be checked against the file system first then put that middleware before routing.

        public void Configure(IApplicationBuilder app)
        {
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapReverseProxy();
            });
        }

If you want to use static files as a fallback then put it after routing.

        public void Configure(IApplicationBuilder app)
        {

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by tbonham
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants