Hello, I have an /api/stream api route which uses query params to stream the required audio to the frontend (/api/stream?id=blahblah. It works great in dev mode, but when I build the app, it gives the error @sveltejs/adapter-static: all routes must be fully prerenderable, but found the following routes that are dynamic:- src\routes/api/stream. Is such a thing not possible with Tauri?
#SvelteKit dynamic api routes with Tauri?
13 messages · Page 1 of 1 (latest)
There's no nodejs runtime in a tauri app and therefore no sveltekit server == no serverside features
Really? But why does it work in dev mode? Spent several days working on streaming and now I found its not supported :(. Anyways, any other way to such a thing in Tauri? Because this seems like a somewhat common use-case. Can I use a separate node server or do I have to implement it in the rust backend?
Cuz in dev mode you actually have a node server that is running
Depends on what the api does but either serve it separately or you could indeed use a nodejs sidecar
But you lose all the principe of Tauri lol
So is there any way to create a REST api in the rust backend? I am not familiar with the rust ecosystem, what crate can I use? There is the http tauri api and the warp crate. Can any of them substitute SvelteKit server routes or express? I don't thing i can use the commands system, since html audio tag needs a url to stream audio.
why use a HTTP api on the backend when you could invoke tauri commands?
The HTML audio tag that renders the audio manages all the buffering, caching, chunking itself, given a src url. If I use tauri commands to get the audio chunks, I think I will also have to somehow do manually what the audio tag does automatically. I might be wrong on this though.
well if you are willing to use rust and run a backend HTTP server (which I have done before as well for oauth), you could use something like axum
thanks! I'll check it out.
If you don't need Linux support then custom protocols would work too - if the files you wanna stream are on the fs you could even use the built-in asset protocol
https://tauri.app/v1/api/js/tauri/#convertfilesrc