r0x0r / pywebview

Build GUI for your Python program with JavaScript, HTML, and CSS
https://pywebview.flowrl.com
BSD 3-Clause "New" or "Revised" License
4.65k stars 540 forks source link

Not allowed to request resource error when non localhost server is called in javascript console #1161

Closed sastradhar closed 1 year ago

sastradhar commented 1 year ago

When pywebview.api.function is called in javascript and the server is not localhost we get Not allowed to request resource error in the js debug console. For local host the code works well. I recently update pywebview to the 4.2.2 version and this error started appearing. My code used to work in the old 3.x release. In my case the when I click on the error I am directed to this code.

function anonymous(studypath, studyid, username, band, canreport, IsAnon) { var id = (Math.random() + '').substring(2); var promise = new Promise(function(resolve, reject) { window.pywebview._checkValue('clickedonstudy', resolve, reject, __id); }); window.pywebview._bridge.call('clickedonstudy', arguments, id); return promise; }

r0x0r commented 1 year ago

This is an unintended side effect on the new GTK JS bridge in 4.0, ie with a local web server. The old way (passing data via window.title) was buggy and inherently broken, so it had to be replaced. I don't know if anything can be done about this, other than to think of another way to make dialog between JS and Python possible.

r0x0r commented 1 year ago

@sastradhar I found a native way for JS bridge. The code is in the master, check it out.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.