Home > Web Front-end > JS Tutorial > How to Resolve \'XMLHttpRequest cannot load\' CORS Error with Unsupported Protocol Schemes?

How to Resolve \'XMLHttpRequest cannot load\' CORS Error with Unsupported Protocol Schemes?

Barbara Streisand
Release: 2024-12-01 10:01:13
Original
966 people have browsed it

How to Resolve

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/';
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template