Unable to access Webapi from one server from Angular app on another server
Hi,I have my Webapi on one server say http://localhost:51989/
and my Angular app is running on http://localhost:65307/
I'm unable to call the api from my AngularApp, I'm getting 500 error due to my Api is not letting to access. although I can do successful get on my browser.
Few things I did was:
1. config.EnableCors(); in WebApiConfig.cs
2.
[EnableCors("http://localhost:65307/", "*", "*")]
public class EventController : ApiController
{
[EnableCorsAttribute("http://localhost:65307/", "*", "*")]
public JToken Get(string id = null)
{}
[EnableCorsAttribute("http://localhost:65307/", "*", "*")]
public void Post(string id, JObject eventData)
{}
}
3. in Providers/ApplicationOAuthProvider.cs
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin",new[] { "http://localhost:65307/" });}