I am doing a simple project on dijit.Tree.whenever I run the program it is giving below error
uncaught reference error: dojo is not defined
and sometimes
XMLHttpRequest cannot load file:///C:/Users/Desktop/dojoapps/dojo/dojo/main.js. Cross origin requests are only supported for HTTP.
I have seen many Questions on this error.Today I got the same error and resolved within seconds.so,I am giving the solution here :
It is just because your path is incorrect and it is not mapping to dojo.js
First step is,make sure that your path to dojo folder is correct.
And Also,Even if you Map correctly you will see the below error in chrome.
XMLHttpRequest cannot load file:///C:/Users/Desktop/dojoapps/dojo/dojo/main.js. Cross origin requests are only supported for HTTP.
The simple solution is,run your code with any server like Apache Tomcat and replace your path with in your code with http://localhost:8080/
Related
I was having the SharedArrayBuffer error as described in this other issue and to fix I added the cross origin isolation as suggested (also suggested here) by adding the headers
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
After that, now when I try to run the code I just got Uncaught ReferenceError: FFmpeg is not defined. The error is happening on Firefox
My code is:
<script src="https://unpkg.com/#ffmpeg/ffmpeg#0.10.0/dist/ffmpeg.min.js"></script>
<script>
const { createFFmpeg, fetchFile } = FFmpeg; //error happens here
const ffmpegInstance = createFFmpeg({
corePath: 'https://unpkg.com/#ffmpeg/core#0.10.0/dist/ffmpeg-core.js',
log: true,
});
</script>
Before that, on Brave browser the process ran ok without having to add the Cross origin headers and also FFmpeg variable was defined.
The reason is that for SharedArrayBuffer to work, the scripts using its functionality must opt-in via those headers as well.
Unfortunately, https://unpkg.com/ currently doesn't serve scripts with COOP/COEP headers.
To make your application work again, you'll have to either copy and self-host those sources from your own origin, or bundle them as part of your application.
I'm trying to use ARR to get layers from GeoServer to load on a web map hosted on IIS because I keep getting the "No 'Access-Control-Allow-Origin' header is present on the requested resource." error in my console.
I tried adding an ARR rule to the IIS website, but it doesn't change anything. I think that I might not understand well of this is supposed to work.
The rule is:
Requested URL: Matches the pattern
Pattern: geoserver.+
Rewrite URL: http://localhost:8080/{R:0}
Anyone can point what I'm doing wrong ?
Edit:
I followed this procedure: https://forums.iis.net/t/1189344.aspx but it doesn't work, I'm getting a Failed to load resource: net::ERR_CONNECTION_REFUSED error. My IIS server adress is http://localhost:1234/ and geoserver is http://localhost:8080. I wrote the localhost:1234 url in the GeoServer global setting, but I couldn't change the parameter in the web.xml as it doesn't seem to exist in my geoserver version (2.8) ...
So I am writing an application in Node-Webkit/NW.js that needs a "Login to LinkedIn" button. We have to use a custom protocol/domain in order to allow hooking into the Dropbox API (let's call it app://example).
In the Application Details on the developer portal, for JavaScript API Domains I have "app://example" and "example." However, when I attempt to use my API key inside the application I get the following error:
Uncaught Error: JavaScript API Domain is restricted to example
Does LinkedIn not allow custom protocols, and only http/https? This is a big problem for us and I hope someone is able to answer.
Use a server in a controlled environment rather than the developer console to avoid this error.
Use a redirect from the https:// protocol to the app:// protocol in that controlled environment. Here is the process:
Essentially, where I was previously seeing "Not allowed to load local resource: app://whatever/somefile.html", addOriginAccessWhitelistEntry eliminates the error and I see the appropriate app:// resource in the address bar with the following new error in the console: "Uncaught ReferenceError: require is not defined"
That said, if I force a refresh at this point the resource rendering occurs as expected.
nw.App.addOriginAccessWhitelistEntry('http://github.com/', 'app', 'myapp', true);
References
nw.js: app:// Protocol doesn't load for OAuth Redirect
nw.js: addOriginAccessWhitelistEntry
I have two of the same site. My 1st site is http://educationaboveall.org/ and the 2nd is http://www.savantgenius.com .
1st site is loading properly on every device without any error but the 2nd (www.savantgenius.com) site is not loading properly in mobile and table devices. It is only loading properly in desktop browser. I have also found 32 console error.
Are there any jQuery issues? And please tell me how to be able to fix it.
I'm getting the "XMLHttpRequest cannot load
file:///D:/Work%20File/My%20Work%20File/mY%20Work%20Backup/Sophie/Work%20File/footer.html.
Cross origin requests are only supported for HTTP." and "Error: Failed
to execute 'send' on 'XMLHttpRequest': Failed to load
'file:///D:/Work%20File/My%20Work%20File/mY%20Work%20Backup/Sophie/Work%20File/footer.html"
error, but I don't know what's causing it nor how to fix it.
Please see the screenshot - http://prntscr.com/4fm0d8
I Think that you should call it from a http webserver and not like simple file in browser. This mean request a file in a web server like http://localhost/XML/catalog.html not from file:///E:/Projects/XML/catalog.html.
It is as the message says:
cannot load file:///D:/Work%20File/My%20Work%20File/mY%20Work%20Backup/Sophie/Work%20File/footer.html. .
You are referencing to a file on a Windows boxes filesystem and not in a webservers folder.
Second: you have a CORS-issue (which in this case is caused by the filesystem reference)
Cross origin requests are only supported for HTTP
See MDN for more infos.
To solve the issue, you have to configure your webserver to allow such requests. Check your webservers manual.
I had the same problem with my InfluxDB connection and it turns out I did not prepend the URL settings in the datasource with 'http://'. This could be nicer in Grafana, e.g. mentioning there is no protocol defined for accessing the source.
In your case it's clear that you somehow configured Grafana to look for D:\, which is not accessible for your browser. So check your data source URL.
Final product: take a file called theFile.txt which is saved with the js and HTML file and have it broken up by line into an array.
Problem: Works fine in Firefox but revives the following error in Google Chrome:
XMLHttpRequest cannot load file:///C:/Users/(my name)/Documents/testFile/theFile.txt. Received an invalid response. Origin 'null' is therefore not allowed access.
Javascript code:
$('#infoStore').load('theFile.txt', function(result) {
text = result;
console.log('here: '+text);});
HTML code for infoStore:
<div id="infoStore" hidden="true"></div>
Thank you in advance for your assistance. I will be online to answer questions often.
That's because Chrome treats all origins using the file: protocol as being different from each other, and so the Same Origin Policy comes into play. It's just a security choice distinction between Chrome and some other browsers.
You basically can't use ajax with local files served via the file: protocol. (In Chrome.)
You could read the file using the File API (this answer shows how), but of course that has limitations (not least that the user has to give you the file to read, either via <input type="file"> or drag and drop).
This happens because of Same-Origin-Policy. You should load that file from webserver, not from local directory.
If you want to access local file in chrome ??
Sometimes it’s cool to debug and test javascript applications in Chrome but you want to read / write to local files. Example: you’re looking to use ajax and do a $.getJSON(‘json/somefile.json’). Chrome by default won’t allow this and will throw an error similar to
Failed to load resource: No 'Access-Control-Allow-Origin'
header is present on the requested resource.
Origin 'null' is therefore not allowed access.
Or
XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin'
header is present on the requested resource.
Origin 'null' is therefore not allowed access.
Chrome does have a switch to enable this, it’s quite easy to turn on. You’ll need to make sure Chrome is closed completely, and run chrome with the ‘–allow-file-access-from-files’ flag. Ie:
C:\Users\<user>\AppData\Local\Google\Chrome\Application>
chrome --allow-file-access-from-files
Or you should be able to run:
%localappdata%\google\chrome\application\chrome --allow-file-access-from-files
I’ve made the below into a .bat file I use, if you find it helps.
start "chrome" %localappdata%\google\chrome\application\chrome --allow-file-access-from-files
exit
To see if the flag is set, you can visit: chrome://version/ and look at the Command Line section and you should see –allow-file-access-from-files
You’ll most likely need to run this with at least admin access, and I would caution visiting unknown sites with this setting on, as they could capitalize on your setting and potentially read local files.
REF: Reference Link -Allow Local File Access in Chrome (Windows)