Skip to content

Some questions about --remote-allow-origins and how I solved it #30

@hypocrite182

Description

@hypocrite182

I often use PyChromeDevTools to debug Android Webview pages, which is an excellent open source library.
Recently, I discovered that due to the upgrade of the Android Webview kernel, PyChromeDevTools cannot connect to Android Webview normally because of the security policy --remote-allow-origins.
However, I couldn't specify Android to use this command line parameter to start Webview, and encountered a similar error: #28.

After a long period of research and attempts, I think PyChromeDevTools needs to be optimized:
In the PyChromeDevTools source code _init_.py, lines 60, 67, and 71,
websocket.create_connection(wsurl)
should be changed to
websocket.create_connection(wsurl, suppress_origin=True).

Now let me explain, the modified code blocks the Origin header in the first http connection for WebSocket connection. Chromium does not seem to be restricted by the parameter --remote-allow-origins when the Origin header does not exist.

After this modification, my Android Webview can use PyChromeDevTools to restore normal connection.
The above is my experience sharing, I hope it can help people in need:)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions