CORS Error: "Requests are Only Supported for Protocol Schemes: http..."
The "XMLHttpRequest cannot load" error occurs when cross-origin requests are attempted without the proper protocol schemes. In this case, the Angular Service is trying to access the JSON string from the Express backend at localhost:4201/ticker, but is encountering a CORS error.
To resolve this issue, the protocol scheme must be explicitly included in the request URL in the Angular Service. The error message indicates that only http, data, chrome, chrome-extension, and https schemes are supported. Therefore, the URL should be modified to include http:// before localhost:
this._baseUrl = 'http://localhost:4201/';
With this adjustment, the Angular Service can now make cross-origin requests using the http scheme, addressing the CORS error and allowing the JSON string to be retrieved successfully.
The above is the detailed content of How to Resolve \'XMLHttpRequest cannot load\' CORS Error with Unsupported Protocol Schemes?. For more information, please follow other related articles on the PHP Chinese website!