While building an ecommerce I decided to write the backend where I keep all my products in C# using the .NET API. I connected the back-end & front-end with CORS:
app.UseCors(opt =>
{
opt.AllowAnyHeader().AllowAnyMethod().AllowCredentials().WithOrigins("http://localhost:19006");
});
I use fetch API & React Native on the client side to receive the products
useEffect(() => {
fetch('http://localhost:5000/api/products')
.then(response => response.json())
.then(data => setProducts(data))
}, [])
When I enter npm expo start --web in the terminal, I can see that I'm successful. The problem occurs when I run the same app on my phone using regular npm start & connecting my phone to expo. I don't get the products from the app, I get this error:
I believe this is happening because it is no longer running on localhost, it says it's running on exp://127.0.0.1:19002 . The problem is I have no idea how to connect to that. Some help would be really appreciated.