https://linen.dev logo
Serve a SPA + API
# help
a
Can shuttle serve a SPA + API using Axum? Does shuttle impose some limitations to do this? Does it need /dist to be on a special location? etc. Currently I am using this:
Copy code
const FRONT_PUBLIC: &str = "./frontend/public";
...
Router::new()        .fallback(get_service(ServeDir::new(FRONT_PUBLIC)).handle_error(handle_error))
s
This would require static files support which we don't have (yet). This discussion has a workaround for the meantime https://discord.com/channels/803236282088161321/1028356911717949491/1028362100042649773
a
@stocky-kangaroo-53672 it works locally as-is - it also works when I deploy with /templates folder using tera. So I see no reason why not to work with a /dist folder. Am I missing something?
s
In the (prod) deployed version, we move the compiled file to a persistent folder so it won't find something like a
./dist
folder (since the folder isn't copied too) during runtime. It works locally, since we don't copy the compiled file for local runs and therefore the
./dist
folder is in the expected place So the entire serving of any folder works as expected. It's finding the location of the folder during runtime that is the problem in prod.
Btw, is the
/templates
folder being used during compile time?
a
You are right, templates are embedded into the binary.
s
Ah I see, yip finding folders work at compile time since the file has not been moved yet