You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specs/HostResourceMapping.md
+79-45Lines changed: 79 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,52 +7,61 @@ To access local files in WebView2, define a virtual host name to local folder ma
7
7
and then refer to local files under the folder with a normal http/https url with the virtual host name.
8
8
9
9
# Examples
10
-
Suppose the app has index.html file in `asset` sub folder in the folder where its exe file is. The following code snippet demonstrates how to define a mapping
11
-
for `appassets.webview2.microsoft.com` host name so that it can be accessed using normal http/https url like https://appassets.webview2.microsoft.com/index.html.
10
+
Suppose the app has index.html file in `asset` subfolder located on disk under the same path as the app's executable file.
11
+
The following code snippet demonstrates how to define a mapping for `appassets.example` host name so that it can be accessed
12
+
using normal http/https url like https://appassets.example/index.html.
webView.Source = new Uri("https://appassets.webview2.microsoft.com/index.html");
26
+
webView.Source = new Uri("https://appassets.example/index.html");
26
27
```
27
28
28
29
## WinRT
29
-
Suppose the app has index.html file in a `book1`sub folder of the app's LocalFolder folder. The following code snippet demonstrates how to define a mapping
30
-
for `book1.appassets.webview2.microsoft.com` host name so that it can be accessed using normal http/https url like https://book1.appassets.webview2.microsoft.com/index.html.
30
+
Suppose the app has index.html file in a `book1`subfolder under the app's LocalFolder folder. The following code snippet demonstrates how to define a mapping
31
+
for `book1.example` host name so that it can be accessed using normal http/https url like https://book1.example/index.html.
Choose a virtual host name that will not be used by real sites.
43
-
If you own a domain (like example.com), an option is to use a sub domain reserved for the app (like my-app.example.com).
44
-
We have also reserved a special domain appassets.webview2.microsoft.com for this usage.
45
-
43
+
You should typically choose virtual host names that are never used by real sites.
44
+
If you own a domain such as example.com, another option is to use a subdomain reserved for the app (like my-app.example.com).
45
+
[RFC 6761](https://tools.ietf.org/html/rfc6761) has reserved several special-use domain
46
+
names that are guaranteed to not be used by real sites (for example, .example, .test, and
47
+
.invalid.)
48
+
Apps should use distinct domain names when mapping folder from different sources that
49
+
should be isolated from each other. For instance, the app might use app-file.example for
50
+
files that ship as part of the app, and book1.example might be used for files containing
51
+
books from a less trusted source that were previously downloaded and saved to the disk by
52
+
the app.
46
53
The host name used in the APIs is canonicalized using Chromium's host name parsing logic
47
54
before being used internally.
48
-
All host names that are canonicalized to the same string are considered identical.
49
-
For example, `EXAMPLE.COM` and `example.com` are considered the same host name.
50
-
An international host name and its puny coded host name are considered the same host name.
51
-
There is no DSN resolution for host name and trailing '.' is not normalized as part of canonicalization.
52
-
Therefore `example.com` and `example.com.` are treated as different host names. So are `virtual-host-name` and `virtual-host-name.example.com` when the DNS suffix of the machine is `example.com`.
53
-
54
-
Give only minimal cross origin access necessary to run the app. If there is no need to access local resources
55
-
from other origins, use COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY.
55
+
All host names that are canonicalized to the same string are considered identical.
56
+
For example, `EXAMPLE.COM` and `example.com` are treated as the same host name.
57
+
An international host name and its Punycode-encoded host name are considered the same host
58
+
name. There is no DNS resolution for host name and the trailing '.' is not normalized as
59
+
part of canonicalization.
60
+
Therefore `example.com` and `example.com.` are treated as different host names. Similarly,
61
+
`virtual-host-name` and `virtual-host-name.example.com` are treated as different host names
62
+
even if the machine has a DNS suffix of `example.com`.
63
+
Specify the minimal cross-origin access necessary to run the app. If there is not a need to
64
+
access local resources from other origins, use COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND_DENY.
56
65
57
66
# API Notes
58
67
See [API Details](#api-details) section below for API reference.
0 commit comments