hlwhl / webview_cef

WebView for Flutter Desktop Apps using CEF(Chromium Embedded Framework) [Work in Progress]
Apache License 2.0
158 stars 44 forks source link

Blocked by CORS policy #110

Closed MobileD3v3l closed 2 months ago

MobileD3v3l commented 4 months ago

Hello.

With your plugin I've been able to load both 'file:///index.html' and 'localhost:8040/index.html'.

The problem arises when four inside index.html is called an external url: i.e. www.google.com. Then a core problem appears:

[0226/150438.520879:INFO:CONSOLE(0)] "Access to fetch at 'https://content.example.com/html/index.html' from origin 'http://localhost:8030' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.", source: http://localhost:8030/index.html (0)

Is there a way to disable cors policies from webview_cef?

Thanks!

SinyimZhi commented 4 months ago

@MobileD3v3l Of course, it has a global setting that can ignore all browser security settings, but be careful to only load pages that you fully trust. You can set it after this line like follow screenshot. image And there is another way which more securely is set white list, but we have not finish the api yet...

MobileD3v3l commented 4 months ago

Thank you very much! It works and the pages loaded are secure (our own server).

Waiting for the white list feature.