I have developed an angular 7 app with express backend. Express running on localhost:3000 and angular client is running on localhost:4200.
In the
I have been working with Angular cli and .net Framework in server side.
To solve this problem, I just ennable CORS interaction in server side using the following steps:
Install-Package Microsoft.AspNet.WebApi.Cors -Version 5.2.6
And then, into WebApiConfig class:
Add using System.Web.Http.Cors;
Inside Register(HttpConfiguration config) method:
var cors = new EnableCorsAttribute("http://localhost:4200", "*", "*"); config.EnableCors(cors);
or
var cors = new EnableCorsAttribute("*", "*", "*"); //origin, headers, methods config.EnableCors(cors);