CORS Error: “requests are only supported for protocol schemes: http…” etc

后端 未结 1 787
野趣味
野趣味 2020-11-22 10:03

I am trying to run a simple application. I have an Express backend which returns a JSON string when visited at localhost:4201/ticker. When I run the server and

相关标签:
1条回答
  • 2020-11-22 10:32

    XMLHttpRequest cannot load localhost:4201/ticker. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

    Any time you see that “only supported for protocol schemes” message, it almost certainly means you’ve just forgotten to put the https or http on the request URL in your code.

    So in this case, the fix is to use the URL http://localhost:4201/ticker in your code here:

    this._baseUrl = 'http://localhost:4201/';
    

    …because without the http:// there, localhost:4201/ticker isn’t really the URL you intend.

    0 讨论(0)
提交回复
热议问题