AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Problem with RiveScript JS version

Help i’m very new and i got this error: jquery-3.2.1.js:9566 Failed to load file:///C:/xxxxxx/NewProject/Other app1/brain.rive: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

let bot = new RiveScript();

  [ # 1 ]

Hi, Daniel, and welcome to smile

I took the liberty of creating a new thread for you, both because your problem is not related to the thread you posted in, and also because that thread was a bit old, and you may not have gotten a reply there if it stayed. It’s always a good idea to create a new thread whenever you have a question to ask, unless it’s about a similar problem that is being currently discussed. wink

I know very little about RiveScript, as I’m a developer for a different chatbot engine, but I’m familiar with JavaScript and CORS (Cross-Origin Resource Sharing), which is what your issue seems to be running afoul of. Modern web browsers are VERY security conscious these days, and scripts that try to access different resources from different locations have very strict rules that they have to follow. For example, JavaScript that runs in a non-secure web environment (e.g. HTTP://) can’t gain access to other scripts within a secure (e.g. HTTPS://) one, and one that runs from a “local” environment (e.g. FILE:///) generally can’t access web-based resources (e.g. HTTP:// or HTTPS://). Going only from the error message you’ve posted (since there’s not really any other information given), I’d have to guess that your RiveScript file (file:///C:/xxxxxx/NewProject/Other app1/brain.rive) is trying to access information or data from a source OTHER than the file system. If this is the case, you’re going to need to put all of your resources into the same “origin” (either HTTP, HTTPS or FILE) in order for everything to play well together. Otherwise you’re going to continue to have the same problem.

Of course if this is NOT the case, you’ll need to provide more information than you’ve given us so that we can assist you better. cheese


  [ # 2 ]

Source Code snippet from RiveScript.js file:

  int loadFile (string path || array path[, on_success[, on_error]])
  Load a RiveScript document from a file. The path can either be a string
  that contains the path to a single file, or an array of paths to load
  multiple files.

Maybe you meant an “.rs” file extension?

let bot = new RiveScript({
debug:     debugMode

And, how about trying debug mode?


  [ # 3 ]

Hi Daniel

As Dave mentioned, modern web browsers are very security-conscious. The specific issue you’re seeing is that you appear to have opened the web page from your local filesystem, and it’s trying to access other local files (the file:/// URI).

For an example why the browser would block that: suppose you got a spam email with a .html attachment, and when you open it, it tries to ajax-load a sensitive file like /etc/passwd to enumerate all the users on your system, and then find “some way” to send that file to an attacker. Browsers enforce a same-origin policy, so a page on one domain (or local filesystem) can’t make ajax requests to other domains, but the malicious web page might just create a <form> and auto-submit it to a remote URL.

RiveScript-JS includes an example web page that uses RiveScript here:

On the README for that example it mentions the browser security issues and how you should upload all the files to a real web server for testing. Currently, if you have a JavaScript dev environment set up, you can run `grunt server` which will run a local web server and open your browser to it automatically, and then the RiveScript files can be successfully loaded via ajax.


  [ # 4 ]

In short, it is not a problem with RiveScript.


  login or register to react