I want to use http://sg.media-imdb.com/suggests/ API url for using imdb autocomplete in my test project, but when I try use it I get CORS error.
Failed to load http://sg.media-imdb.com/suggests/t/t.json: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. home.component.ts:52
TypeError: Failed to fetch
Can anyone tell me how I can fix this problem?
When you use already a web server, you have to define your CORS Settings. Here is a good intro to that. https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS You might also need adoc how to set it for your Webserver.
When you still in development you can either use a browser plugin which disables cors or use angular proxy to redirect your calls https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/proxy.md