Skip to content

[Question] Is there currently a way to intercept browser requests and modify headers? #71

@russkyc

Description

@russkyc

In the wpf webview I believe this is the implementation

private void webView_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
      //Following line is MUST if you want to use WebResourceRequested Event
      webView.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All);
      webView.CoreWebView2.Settings.UserAgent = "MY-AGENT";
      webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
      webView.CoreWebView2.Settings.AreBrowserAcceleratorKeysEnabled = false;
      webView.CoreWebView2.WebResourceRequested += CoreWebView2_WebResourceRequested;
}

private void CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e)
{
      e.Request.Headers.SetHeader("X-Authorization", "My Auth");
}

Is there currently a way to do something similar in Avalonia.Webview? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions