2

I setup a reactredux/dotnetcore app with the dotnet new reactredux command. I'm trying to test my API but whenever I try to fetch something, the only thing I get back is the index.html from the react client. Even for endpoints I have not specified.

I have my app running on localhost 5000 and 5001 and for both I get the same result.

Did I forget to set some setting?
Am I using the wrong address? Where can I find the right one?

1 Answer 1

2

ASP.NET Core SPA templates will redirect you to the SPA index.html static page whenever the MVC backend doesn't have a matching route for the request. Add this controller to your application and see if you can get a response from it. If it works compare the changes to the rest of the controllers you're calling:

[Route("api/[controller]")]
public class TestController : ControllerBase
{
    [Route("[action]")]
    public IActionResult Test() => Content("Hello World!");
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.