Access-Control-Allow-Origin while loading local file

Having problems with building or using the JCEF Java binding? Ask your questions here.

Access-Control-Allow-Origin while loading local file

Postby Noman » Wed Aug 26, 2015 5:07 am

Hi,
I am using jcef to load my offline html+javascript pages in chrome browser. Currently i start getting a problem when i try to load a properties file using jquery-i18N plugin.
this is how i am loading properties file in javascript:
Code: Select all
jQuery.i18n.properties({
    name: 'messages_nn_NO',
    path: '../../../',
    mode: 'map'
});



and then i am getting this console message
Code: Select all
"XMLHttpRequest cannot load file:///home/adminuser/code/hp_healthbrowser/healthbrowser-linux/target/classes/messages_nn_NO.properties?_=1440579166487. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.", source: file:///home/adminuser/code/hp_healthbrowser/healthbrowser-linux/target/classes/web/partials/dialpad/phone.html?callType=outGoingCall (0)



Is there any cef settings from where i can set cross domain origin or make it disable for local files loading.
Noman
Newbie
 
Posts: 7
Joined: Wed Feb 11, 2015 9:52 am

Re: Access-Control-Allow-Origin while loading local file

Postby AndoniV » Wed Sep 02, 2015 12:35 pm

Hello Noman

I've been doing something similar, calling a jquery soap request and had the same cross site domain issue, what helped me for now was to pass a "--disable-web-security" argument to the cefApp instance like this:

ArrayList<String> args = new ArrayList<>();
args.add("--disable-web-security");

cefApp_ = CefApp.getInstance(args.toArray(new String[args.size()]));

This may not be the best solution to the issue but has helped me carrying on with the development.

Hope this helps
AndoniV
Newbie
 
Posts: 6
Joined: Wed Mar 18, 2015 5:29 pm

Re: Access-Control-Allow-Origin while loading local file

Postby Noman » Thu Apr 21, 2016 5:53 am

Hi, Thanks for sharing this hack. Can you please share a source from where you find this. I am trying to locate a documentation of JCEF3 from where i can find something for enable touch screen events. Have you any idea on that.
Noman
Newbie
 
Posts: 7
Joined: Wed Feb 11, 2015 9:52 am

Re: Access-Control-Allow-Origin while loading local file

Postby magreenblatt » Thu Apr 21, 2016 8:12 am

Noman wrote:Hi, Thanks for sharing this hack. Can you please share a source from where you find this. I am trying to locate a documentation of JCEF3 from where i can find something for enable touch screen events. Have you any idea on that.

Please don't post the same question in multiple places. See viewtopic.php?f=17&t=14107&p=30517#p30517.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 28 guests