Empty page when `serve`ing a default Fullstack project via `dx build -r` (no server binary)
Problem
After creating and building a default project, I run serve which works like a file serving server. Since dist doesn't include any server binary, this means that the project can be run without one. Which is strange as SSR and everything else that relies on server logic disappears. So another question is why dx build doesn't produce the necessary server part. But just page rendering and client-side logic should still work with just serve. Instead, it downloads everything it needs, including the Wasm file, and the page is empty with the title and an icon up top.
Steps To Reproduce
cd /tmp && dx new --subtemplate Fullstack -o router=false -o styling=Vanilla project && cd project && dx build -r && serve -s dist
The styling and router value don't matter.
Expected behavior
A page with the same layout as running via dx serve.
Screenshots
Environment:
- Dioxus version: 0.5.2 (d6fc5dc5bd3318699a3c5d2b3ba181a597d11f22)
- Rust version: 1.80.0-nightly
- OS info: Pop!_OS
- App platform: fullstack
Questionnaire
- [x] I'm interested in fixing this myself but don't know where to start
- [ ] I would like to fix and I have a solution
- [ ] I don't have time to fix this right now, but maybe later
It looks like the automatic platform detection based on features enabled on the dioxus package in cargo.toml is not working for dx build. Running dx build -r --platform fullstack correctly builds the web and server build
--platform <PLATFORM>
Build platform: support Web & Desktop [default: "default_platform"] [possible values: web, desktop, fullstack, fullstack]
Somehow there is a duplicate.
It looks like the automatic platform detection based on features enabled on the dioxus package in
cargo.tomlis not working fordx build.
Is it? Is default_platform being ignored if automatic detection is enabled? If changing web to desktop, then it fixes the problem. It should be this way in the template regardless. https://github.com/DioxusLabs/dioxus-template/pull/41
But what about serve? Is there a logic on the client to only hydrate the existing HTML, but there is no logic that builds it from the scratch? Which would mean that you can't use a server that just serves static files.