Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we lift the CORS restrictions in pywebview? #1375

Open
lightpig7 opened this issue Apr 29, 2024 · 3 comments
Open

How can we lift the CORS restrictions in pywebview? #1375

lightpig7 opened this issue Apr 29, 2024 · 3 comments

Comments

@lightpig7
Copy link

image

@r0x0r
Copy link
Owner

r0x0r commented Apr 29, 2024

It might be possible by modifying response headers. There is an ongoing effort to add header editing support in #1371

@lightpig7
Copy link
Author

Thank you very much for your reply. I would like to ask if there is a direct interaction function now. For example, there is window.send('str') in the python code, and then there is a Javascript function in the webview to receive it. The application scenario is when a js calls python-api. , can return data multiple times, for example: thread

@r0x0r
Copy link
Owner

r0x0r commented Apr 29, 2024

You can proxy XHR requests via JS API. In other words you would fetch data in Python and make it available to your frontend via JS API. Something like this

Python

class API:
  def fetchData(self):
     return urlopen(..)

webview.create_window(..., js_api=Api())

Javascript

pywebview.api.fetchData().then(response => response)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants