Replacing spa.UseReactDevelopmentServer
with spa.UseProxyToSpaDevelopmentServer("http://localhost:3000");
doesn't run the server on port 3000. The Fetch Data page gives the message Unhandled Rejection (SyntaxError): Unexpected token < in JSON at position 0
Calling from Postman returns the message "Couldn't get any response".
The changed source code is:
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseProxyToSpaDevelopmentServer("http://localhost:3000");
// spa.UseReactDevelopmentServer(npmScript: "start");
}
});
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hello! Thanks for contacting us. This sounds like a general question about using ASP.NET Core. While we try to look at and respond to all issues, for questions like this we recommend posting to a community support group like Stack Overflow with the asp.net-core
tag.
I'm aware this issue has been closed. Also, I agree this appears to be more of a usage question, not a bug/problem. However, I thought, I'd share an answer here nevertheless for other visitors of this page.
As I understand it from the source code of ASP.NET Core 3.1, UseProxyToSpaDevelopmentServer()
does not start the dev server. It merely proxies requests, i.e. incoming requests are forwarded to the development server.
In contrast UseReactDevelopmentServer()
will start the react development server. Internally, as of .NET Core 3.1, it will also call UseProxyToSpaDevelopmentServer()
.
@ManfredLange thanks for responding. Your answer will help others.
Most helpful comment
I'm aware this issue has been closed. Also, I agree this appears to be more of a usage question, not a bug/problem. However, I thought, I'd share an answer here nevertheless for other visitors of this page.
As I understand it from the source code of ASP.NET Core 3.1,
UseProxyToSpaDevelopmentServer()
does not start the dev server. It merely proxies requests, i.e. incoming requests are forwarded to the development server.In contrast
UseReactDevelopmentServer()
will start the react development server. Internally, as of .NET Core 3.1, it will also callUseProxyToSpaDevelopmentServer()
.