diff --git a/examples/clang-cdn/README.md b/examples/clang-cdn/README.md new file mode 100644 index 00000000..078e7af7 --- /dev/null +++ b/examples/clang-cdn/README.md @@ -0,0 +1,23 @@ +# Clang with CDN + COEP/COOP headers. + +This example showcases how to use clang with the Wasmer SDK when using a CDN. + + +You'll need to set up the COOP/COEP headers when serving the html file, so it works +properly in the broser: + +``` +Cross-Origin-Embedder-Policy: require-corp +Cross-Origin-Opener-Policy: same-origin +``` + +If you are unable to modify the server to send this headers when serving the html file, +please use the [cdn-coi-serviceworker](../cdn-coi-serviceworker/) example instead. + +You can test this example locally with: + +``` +$ wasmer run . -- --port=8000 +``` + +And then visit http://localhost:8000/ diff --git a/examples/clang-cdn/etc/config.toml b/examples/clang-cdn/etc/config.toml new file mode 100644 index 00000000..675f697e --- /dev/null +++ b/examples/clang-cdn/etc/config.toml @@ -0,0 +1,16 @@ +# Configuration for static-web-server. +# https://static-web-server.net/configuration/config-file/ + +[general] +log-level = "info" + +[advanced] + +# Note: We need COOP and COEP for Cross-Origin Isolation +# https://docs.wasmer.io/javascript-sdk/explainers/troubleshooting#sharedarraybuffer-and-cross-origin-isolation +[[advanced.headers]] +source = "**/*.{js,html,wasm}" +headers = { Cross-Origin-Opener-Policy = "same-origin", Cross-Origin-Embedder-Policy = "require-corp" } +[[advanced.headers]] +source = "/" +headers = { Cross-Origin-Opener-Policy = "same-origin", Cross-Origin-Embedder-Policy = "require-corp" } diff --git a/examples/clang-cdn/index.html b/examples/clang-cdn/index.html new file mode 100644 index 00000000..fe4247eb --- /dev/null +++ b/examples/clang-cdn/index.html @@ -0,0 +1,63 @@ + + + + + + + Wasmer JavaScript SDK + + + + +

+
+ + diff --git a/examples/clang-cdn/wasmer.toml b/examples/clang-cdn/wasmer.toml new file mode 100644 index 00000000..fc0cb4ef --- /dev/null +++ b/examples/clang-cdn/wasmer.toml @@ -0,0 +1,19 @@ +[package] +name = "wasmer/wasmer-sh" +version = "0.4.21" +description = "The wasmer.sh website" +entrypoint = "wasmer-sh" + +[dependencies] +"wasmer/static-web-server" = "^1" + +[fs] +"/public" = "." +"/etc/static-web-server" = "etc" + +[[command]] +name = "wasmer-sh" +module = "wasmer/static-web-server:webserver" +runner = "wasi" +[command.annotations.wasi] +env = ["SERVER_CONFIG_FILE=/etc/static-web-server/config.toml"]