Angular cross-domain request failed

the error is as follows:

clipboard.png

Code:

list(criteria: RecommendModel) {
    return this.http.post("http://music.163.com/weapi/personalized/newsong",
      criteria,
      {
       /* headers: this.headers*/
        headers: new HttpHeaders({
          "Accept": "*/*",
          "Accept-Language": "zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4",
          "Content-Type": "application/x-www-form-urlencoded"
        })
      })
      .toPromise()
      .then((data: any) => {
        return data;
      })
      .catch((err) => {
        console.log(err);
      });
  } 

is there anything else I need to deal with besides setting up headers? The
interface is from
https://binaryify.github.io/N.

.

this definitely cannot be accessed.


is not allowed on the server.

first:


url

secondly:

ajaxjsonpgetpostjsonp
cors,
CORSAJAXCORS  AJAX 

so it won't work just to set up the header on the client side here.


this requires the server to set Access-Control-Allow-Origin: "*" in the response header;
if someone else's API, cannot be added in the response header, you can use this chrome plug-in chrome://extensions/?id=jioikioepegflmdnbocfhgmpmopmjkim to help you cross domains.

Menu