InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request.
sporifolous opened this issue · 3 comments
After running a clean install with dotnet new vue -o VueStarter
then running dotnet run
the project builds and runs, but navigating to localhost:5000
results in an InvalidOperationException
.
InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request. Microsoft.AspNetCore.SpaServices.SpaDefaultPageMiddleware+<>c__DisplayClass0_0.<Attach>b__1(HttpContext context, Func<Task> next) Microsoft.AspNetCore.Builder.UseExtensions+<>c__DisplayClass0_1.<Use>b__1(HttpContext context) Microsoft.AspNetCore.Builder.UseExtensions+<>c__DisplayClass0_2.<Use>b__2() Microsoft.AspNetCore.SpaServices.SpaDefaultPageMiddleware+<>c__DisplayClass0_0.<Attach>b__0(HttpContext context, Func<Task> next) Microsoft.AspNetCore.Builder.UseExtensions+<>c__DisplayClass0_1.<Use>b__1(HttpContext context) VueCliMiddleware.VueCliMiddlewareExtensions+<>c__DisplayClass5_1.<CreateProxyRequestDelegate>b__2(HttpContext context) Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Hi, thank you for reporting the issue! I was able to reproduce it, now I have to understand why VueCliMiddleware cannot locate the index file. I will investigate the issue tomorrow.
When you start the app from VS Code or VS 2019 it works as expected.
The problem is line 64 in Startup.cs:
npmScript: (System.Diagnostics.Debugger.IsAttached) ? "serve" : null,
you can set it in the following way:
npmScript: env.IsDevelopment() ? "serve" : null,
.
When there's no debugger attached, client app does not start.
Yep, running in debug mode from VS 2019 works great.
This is exactly what I ended up doing to get it working. Glad to hear this is the recommended fix.
Thanks for getting back to me so quickly!