Skip to content

Content-Type for WebView2.Stream is Missing #7

Description

@Nigh

if (Target is WebView2.Stream) {
Args.Response := ICoreWebView2.Environment.CreateWebResourceResponse(Target, 200, "OK", "")
return
}

In the compiled script, if you add resources to the RC section of the exe, the files will all be loaded with the WebView2.Stream type, and at that point the Router won't add the correct Content-Type for them, which will cause the page to not display properly.

Adding the corresponding Content-Type for the type you're using as below can solve the problem temporarily, but a uniform and reliable way to handle it is needed here.

if (Target is WebView2.Stream) {
    Headers := ""
	if(RegExMatch(Args.Request.Uri, "i)\.js$")) {
		Headers .= "Content-Type: text/javascript;"
	}
	if(RegExMatch(Args.Request.Uri, "i)\.svg$")) {
		Headers .= "Content-Type: image/svg+xml;"
	}
    Args.Response := ICoreWebView2.Environment.CreateWebResourceResponse(Target, 200, "OK", Headers)
    return
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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