DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
21.66k stars 834 forks source link

[Feature/Question] How to Change Full Stack Host Address from 127.0.0.1 to 0.0.0.0 #3207

Closed wiseaidev closed 1 week ago

wiseaidev commented 2 weeks ago

Hiya 👋,

I’ve been using Dioxus for a while and love it, especially the server functions model, which simplifies client-server interactions by avoiding traditional APIs. Currently, I’m working on open-source, SaaS production-ready templates, and everything runs as expected for web targets.

However, I hit a roadblock when deploying the full-stack feature with server functions. While Railway builds the container fine, it fails at runtime because it expects the app to bind to 0.0.0.0 address, however Dioxus defaults to 127.0.0.1.

Unlike the host address, we can override the port number with --port flag at build time dx build --release --port 3000. Is there a way to override the host address for deployment on Railway?

For more details, please check the Dockerfile for context.

Best

wiseaidev commented 2 weeks ago

If anyone figures out how to make the full-stack container work on Railway, please lemme know. I've already built our homepage and blog platform using Dioxus full-stack on a purchased domain: Open SASS: https://github.com/opensass/opensass. I plan to host each app on separate paths under the same domain, using iframes for each app: https://github.com/opensass/opensass/blob/main/src/pages/aibook.rs.

jkelleyrtp commented 2 weeks ago

If you're using the latest dioxus pre-release (alpha-4, might be available earlier...) you can set the ports and IP manually with env vars:

IP="0.0.0.0" PORT=8080 ./server

We read the env vars in the server launch here:

https://github.com/DioxusLabs/dioxus/blob/main/packages/fullstack/src/server/launch.rs#L49

which is defined here:

https://github.com/DioxusLabs/dioxus/blob/main/packages/cli-config/src/lib.rs#L47

I don't think this is documented yet but should be within the next week or so.

wiseaidev commented 1 week ago

Thanks lord @jkelleyrtp!

I have overridden the default axum settings: https://github.com/opensass/aibook/blob/main/src/main.rs.

The website is now live on render: https://aibook-8syx.onrender.com

Will setup the domain name later on. Less goooooooooooooooo!

Best!