jchv/go-webview2

How to solve the cross domain problem of js?

Closed this issue · 4 comments

   Access to script at 'file:///D:/goproject/src/test-webview/app/assets/client.80aeb8cb.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome-untrusted, https, edge.

local html

I found a way to solve it, but I encountered a new problem. I want to pass the parameter to ”CreateCoreWebView2EnvironmentWithOptions“, but this seems incorrect
image

You can try to use SetVirtualHostNameToFolderMapping, a simple example

I don't know how to add ICoreWebView2EnvironmentOptions for CreateCoreWebView2EnvironmentWithOptions, always get crush

ICoreWebView2EnvironmentOptionsVTbl

type ICoreWebView2EnvironmentOptions struct {
		queryInterface                            uintptr
		addRef                                    uintptr
		release                                   uintptr
		getAdditionalBrowserArguments             uintptr
		putAdditionalBrowserArguments             uintptr
		getLanguage                               uintptr
		putLanguage                               uintptr
		getTargetCompatibleBrowserVersion         uintptr
		putTargetCompatibleBrowserVersion         uintptr
		getAllowSingleSignOnUsingOSPrimaryAccount uintptr
		putAllowSingleSignOnUsingOSPrimaryAccount uintptr
	}