-
I saw your video on YARP from on dotnet. That was a great video and I loved the examples. Around 6:18 in the video when Chris was showing the route Sam was saying to have the proxy handle the static content without going to a backend server. I was looking for some more information on what Sam was talking to and how would I set that up. I have been following this project since I first learned about with preview 1 or before and this looks great and I'm looking forward to using it in production. Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
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)
{
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapReverseProxy();
});
app.UseStaticFiles();
} Or did you have something else in mind? |
Beta Was this translation helpful? Give feedback.
-
And you can control the mapping of uris to paths using StaticFileOptions. |
Beta Was this translation helpful? Give feedback.
-
@Tratcher Be adding that the app.UseStaticFiles(); that did what I was trying to test. @Tratcher @samsp-msft I'm going to try using StaticFileOptions when I build it out to production use. I have a few thing I want route with this for API calls but do not want to run a server to share my static CSS files for this project. Thank you, |
Beta Was this translation helpful? Give feedback.
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.
If you want to use static files as a fallback then put it after routing.