Load local file get error

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Load local file get error

Postby hawkgao » Fri Aug 12, 2011 3:27 am

Hello,

I load local js file in cef. get following error:

Message: XMLHttpRequest cannot load file:///E:/BN2/BN/BN-build-desktop/html/demo.json. Origin null is not allowed by Access-Control-Allow-Origin.

How to get through it?

Thanks,
Hawk
hawkgao
Mentor
 
Posts: 83
Joined: Thu Aug 04, 2011 9:40 pm

Re: Load local file get error

Postby magreenblatt » Fri Aug 12, 2011 8:21 am

Chromium places security restrictions on what can be done using the FILE scheme. Read the comments for CefAddCrossOriginWhitelistEntry() in cef.h and see http://crbug.com/4197 for a detailed description of those limitations.

You can allow XHR execution from the FILE scheme by setting both CefBrowserSettings.file_access_from_file_urls_allowed and CefBrowserSettings.web_security_disabled to true. However, disabling web security is not recommended for production applications. You should instead use a custom scheme handler or return file contents via OnBeforeResourceLoad().

Regards,
Marshall
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Load local file get error

Postby hawkgao » Fri Aug 12, 2011 9:57 am

I wont use cef to access web content. i will open these settings.
Thanks a lot!
hawkgao
Mentor
 
Posts: 83
Joined: Thu Aug 04, 2011 9:40 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 107 guests