Skip to content

Commit d06f041

Browse files
Arman Ossi Lokokhellang
authored andcommitted
Fixed SpaFallback redirection tests failing by clearing the HTTP response
1 parent 60b8f67 commit d06f041

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/SpaFallback/SpaFallback.csproj

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Version>3.0.0</Version>
4-
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<AssemblyName>Hellang.Middleware.SpaFallback</AssemblyName>
66
<RootNamespace>Hellang.Middleware.SpaFallback</RootNamespace>
77
<Description>SPA fallback middleware for client-side routing</Description>
88
<PackageReleaseNotes>Added automatic host injection</PackageReleaseNotes>
99
<PackageTags>middleware;spa;routing</PackageTags>
1010
</PropertyGroup>
1111

12-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
13-
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
14-
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.1" />
15-
</ItemGroup>
16-
17-
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
12+
<ItemGroup>
1813
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1914
</ItemGroup>
2015

src/SpaFallback/SpaFallbackMiddleware.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Threading.Tasks;
1+
using System.Threading.Tasks;
22
using Microsoft.AspNetCore.Http;
33
using Microsoft.Extensions.Options;
44

@@ -38,6 +38,9 @@ private async Task Fallback(HttpContext context)
3838

3939
context.Request.Path = fallbackPath;
4040

41+
// Reset HTTP response headers, status code and the response body to make room for the redirected endpoint content.
42+
context.Response.Clear();
43+
4144
await Next(context);
4245

4346
if (context.ShouldThrow(Options))

0 commit comments

Comments
 (0)