I'm trying to show pdf files that are locally stored in the user's home dir using an iframe in a Tauri + SvelteKit project.
This does work (i.e. the pdf is shown), but I do get a Javascript error:
at Object.postMessage (<anonymous>:2:62)
at value (<anonymous>:1:90)
at <anonymous>:144:18
at action (<anonymous>:301:16)
at <anonymous>:308:9
at new Promise (<anonymous>)
at invoke (<anonymous>:282:12)
at isPermissionGranted (<anonymous>:395:19)
at <anonymous>:466:3
at <anonymous>:510:3
This is my App.svelte in my minimal reproducible example:
import {convertFileSrc} from "@tauri-apps/api/tauri";
import {homeDir, join} from "@tauri-apps/api/path";
async function convertFileSrcString() {
const homeDirPath = await homeDir();
const filePath = await join(homeDirPath, "example.pdf");
return convertFileSrc(filePath);
}
</script>
<main class="container">
{#await convertFileSrcString() then src}
<iframe id="iframe" title="This works, but throws an error" src="{src}"></iframe>
{/await}
</main>
<style>
</style>
and this is my csp:
"csp": "default-src: 'self'; img-src: 'self'; object-src: 'none'; frame-src: 'self' asset: https://asset.localhost"
and asset protocol config:
"protocol": { "asset": true, "assetScope": [ "$HOME/**" ] }
MRE is here: https://github.com/andreashock101/test-postmessage