thqby / ahk2_lib

MIT License
233 stars 32 forks source link

[Webview2] Add example for bypassing CORS? #44

Closed skygate2012 closed 7 months ago

skygate2012 commented 7 months ago

Can you add an example of using local file and bypassing CORS in the examples? I found this line but don't know where to supply it. HOST_RESOURCE_ACCESS_KIND := { DENY: 0, ALLOW: 1, DENY_CORS: 2 }

thqby commented 7 months ago

https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/winrt/microsoft_web_webview2_core/corewebview2?view=webview2-winrt-1.0.2088.41#setvirtualhostnametofoldermapping

I haven't used this. Here's the documentation.

skygate2012 commented 7 months ago

Reading the docs, I guess that's not what I thought it was. I need to provide this flag --disable-web-security to the EnvironmentOptions so that local html files can call APIs on the internet. Can you show me how?

thqby commented 7 months ago
WebView2.create(hwnd, , , , , { AdditionalBrowserArguments: '--disable-web-security' })
skygate2012 commented 7 months ago

Thanks! That worked like a charm.