Skip to content

Commit 719d49e

Browse files
davidfowlCopilot
andcommitted
Add SPA fallback support to YARP container image
When YARP_ENABLE_STATIC_FILES is enabled, MapFallbackToFile("index.html") is registered after MapReverseProxy() so unmatched requests serve index.html for client-side routing. Set YARP_DISABLE_SPA_FALLBACK=true to opt out. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6458e08 commit 719d49e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Application/Program.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@
3939
app.UseRouting();
4040
app.MapReverseProxy();
4141

42+
if (string.Equals(isEnabledStaticFiles, "true", StringComparison.OrdinalIgnoreCase))
43+
{
44+
var disableSpaFallback = Environment.GetEnvironmentVariable("YARP_DISABLE_SPA_FALLBACK");
45+
if (!string.Equals(disableSpaFallback, "true", StringComparison.OrdinalIgnoreCase))
46+
{
47+
app.MapFallbackToFile("index.html");
48+
}
49+
}
50+
4251
await app.RunAsync();
4352

4453
return 0;

0 commit comments

Comments
 (0)