Jay Jay Jay
Jay Jay Jay

Reputation: 1990

why does asp.net core 3.0 reactjs app only come up after refreshing browser?

I upgraded a .net core 2.2 reactjs app to .net core 3.0. I am running it in Visual Studio 2019. I am getting the following error:

System.Net.Http.HttpRequestException: Failed to proxy the request to http://localhost:51719/, because the request to the proxy target failed.

If I refresh the loading page, it loads fine. Why is the loading slow or erroring out?

Upvotes: 4

Views: 1473

Answers (2)

Kahbazi
Kahbazi

Reputation: 14995

The startup for spa application usually takes some time and if the timeout reached you would get an error.

You can increase the timeout via StartupTimeout property in UseSpa()

app.UseSpa(spa =>
{
    spa.Options.StartupTimeout = TimeSpan.FromMinutes(5);
    spa.Options.SourcePath = "ClientApp";

    if (env.IsDevelopment())
    {
        spa.UseReactDevelopmentServer(npmScript: "start");
    }
});

Upvotes: 4

envalentine
envalentine

Reputation: 531

To make it short:

Angular CLI process takes some time to build the project. If you are running npm start in the command line, wait for it to finish before you start the .net project using F5 or...

some people found a workaround for this: Try to comment out the line:

spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");

in startup.cs file and use

spa.UseAngularCliServer(npmScript: "start");

Hope that makes sense to you.

Upvotes: 1

Related Questions