Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

from origin 'null' has been blocked by CORS policy: Cross origin requests [duplicate]

This error occurred while calling up JSON. I don't know why this error is happening.

$.getJSON(url, function(data){
    console.log(data);
});

Error:

Access to XMLHttpRequest at (this is JSON URL) from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
like image 919
index Avatar asked Sep 12 '25 03:09

index


1 Answers

The error message says it all. You are apparently accessing the page running this script with a protocol scheme other than the several supported for cross-origin requests. This would happen commonly if you are, say, executing a local file in your browser via the file:// protocol and trying to access some URL on the Internet in your $.getJSON call.

like image 77
Ezekiel Victor Avatar answered Sep 14 '25 18:09

Ezekiel Victor