Skip to content

Instantly share code, notes, and snippets.

@srenatus
Created April 15, 2024 10:06
Show Gist options
  • Save srenatus/15e54d12006811bf4d3ea062e861835a to your computer and use it in GitHub Desktop.
Save srenatus/15e54d12006811bf4d3ea062e861835a to your computer and use it in GitHub Desktop.
use @styra/opa from a browser -- for experiments! It's not somethng you want to do in most cases. ⚠️ Run OPA on http://localhost:8181, and `caddy run --config Caddyfile`
:8000 {
handle_path /opa/* {
reverse_proxy http://localhost:8181
}
handle {
root * .
file_server
}
}
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<script type="importmap">
{
"imports": {
"opa": "https://esm.sh/@styra/[email protected]"
}
}
</script>
<script type="module">
import { OPAClient } from "opa";
const opa = new OPAClient(window.location + "opa/");
const main = document.getElementById("main");
main.innerHTML = JSON.stringify(await opa.authorize("system"));
</script>
</head>
<body>
<pre>:)</pre>
<pre id="main"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment