Skip to content

Commit

Permalink
speculation-rules test
Browse files Browse the repository at this point in the history
  • Loading branch information
dbushell committed Dec 6, 2024
1 parent daeaf34 commit a5ff02e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions components/my-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,20 @@
</head>
<body>
<ssr-slot />
<script type="speculationrules">
{
"prefetch": [
{
"source": "document",
"where": {
"and": [
{ "href_matches": "/*", "relative_to": "document" }
]
},
"eagerness": "moderate"
}
]
}
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const middleware: HyperHandle = ({ request, platform }) => {
["x-img-src", "data:"],
// TODO - generate? - Hash for Logo inline styles
["x-style-src", `'sha256-kXLrG8qzlz0MMhgMvdF9YD6tca5CYXeC1iFSTHDsO8w='`],
// Inline speculation rules
["x-script-src", `'sha256-+0XEkXfEhTK/fdyJwJ40zJo+/+nwkO10LI+U1CnyEXA='`],
// "this.rel=`stylesheet`"
["x-script-src", `'unsafe-hashes'`],
["x-script-src", `'sha256-BGXQRYq/G9+8wEtSYSbQRnDRz8/8apfi/W/CUBMh9w0='`],
Expand Down

0 comments on commit a5ff02e

Please sign in to comment.