Aspnetcore.docs: spa.UseProxyToSpaDevelopmentServer("http://localhost:3000") not working

Created on 17 Apr 2019  Â·  3Comments  Â·  Source: dotnet/AspNetCore.Docs

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");
                }
            });


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Source - Docs.ms

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 call UseProxyToSpaDevelopmentServer().

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings