This seems like a simple problem to solve, but I can't figure it out at all. I have followed the React/ASP.NET quick start guide on learn.microsoft.com and I can get everything working just as they have detailed. Where I'm stuck is creating any new routes.
I've added a new controller from the Visual Studio template "API Controller with read/write actions":

Then I try to test this route:
I've tried testing it using the same method as the existing, working fetch call is made from the react app to the back end server:
// The example used in the tutorial and it works OK:
const response = await fetch('weatherforecast');
const data = await response.json();
this.setState({ forecasts: data, loading: false });
// I have imitated this to send a fetch to the "api/test3" route, which doesn't work
const response = await fetch('api/test3');
const data = await response.json();
this.setState({ forecasts: data, loading: false });
But I cant work out what is different for one to be failing and one to be working. I have updated the setupProxy.js file and added the new routes:
const { createProxyMiddleware } = require('http-proxy-middleware');
const context = [
"/weatherforecast",
"/test",
"/api",
"/api/test",
"/api/test3",
"/test2",
];
module.exports = function (app) {
const appProxy = createProxyMiddleware(context, {
target: 'https://localhost:7236',
secure: false
});
app.use(appProxy);
};
I also tried adding these to my package.json:
"private": true,
"proxy": "https://localhost:7236",
I've also tried replacing all of the script in a new controller with the same script as in the working WeatherForecastController.cs from the tutorial. This gives the same error.
