Skip to content

[feat] Web Request Callbacks and Filtering #4899

@ColonelThirtyTwo

Description

@ColonelThirtyTwo

Describe the problem

Tauri should expose a way to register a Rust callback to intercept and modify requests that the application in the web view makes, as part of navigation, resource loading, or via JavaScript API calls. Election has an API to do this here: https://www.electronjs.org/docs/latest/api/web-request

Applications can use this functionality to modify requests for their needs (adding and removing headers for example) as well as preventing access to sites outside the scope of the application, for security.

Describe the solution you'd like

Electron has an API for this already that can serve as a base. Ideally, we can register two callbacks - one called with the request before it is sent and one called with the response after it is received. The callbacks should be passed the complete info about the request and response, and should be able to mutate or reject them.

Alternatives considered

Delegate requests to the core application via either IPC calls or custom protocols. This requires that the inner page be written to use them though, which is not possible for third party sites, and does not address the use case of security hardening.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    📬Proposal

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions