Saturday, February 23, 2019

Access to XMLHttpRequest at 'from origin has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. .net core angular

Issue: The angular application was getting error from API that the origin has been blocked by CORS policy.

Solution: Make sure that the url configured in angular (usually in environment.ts file missing http or https). Example below:


Error Configuration:
export const environment = {
  production: false,
  apiUrl: 'localhost:56425/api'
};

Correct configuration:

export const environment = {
  production: false,
  apiUrl: 'http://localhost:56425/api'

};




Access to XMLHttpRequest at 'from origin has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. .net core angular

Issue: The angular application was getting error from API that the origin has been blocked by CORS policy. Solution: Make sure that the...