W
Wasp2d ago
cooluke.

In development mode can I change the hostname of the server to something other than "localhost?"

I'd like to load my development site from my phone and other machines on my local network. I'm able to pull up the front-end on my phone, but the app doesn't work, because it sends all the server requests to "localhost:3000." I tried setting WASP_SERVER_URL but it didn't work.
3 Replies
kapa.ai
kapa.ai2d ago
Hi @cooluke.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, you can change the hostname of the server in development mode to something other than "localhost" to access your Wasp app from other devices on your local network. Here's how you can do it: 1. First, you need to set the WASP_WEB_CLIENT_URL environment variable for the server. You can do this in your .env.server file:
WASP_WEB_CLIENT_URL=<http://<your-local-ip>:3000>

WASP_WEB_CLIENT_URL=<http://<your-local-ip>:3000>

Replace <your-local-ip> with your computer's local IP address (e.g., 192.168.1.100). 2. For the client-side, you need to set the REACT_APP_API_URL environment variable. You can do this in your .env.client file:
REACT_APP_API_URL=<http://<your-local-ip>:3001>

REACT_APP_API_URL=<http://<your-local-ip>:3001>

Again, replace <your-local-ip> with your computer's local IP address. These steps should allow you to access your Wasp app from other devices on your local network. The front-end will be available at <http://<your-local-ip>:3000,> and it will correctly send API requests to <http://<your-local-ip>:3001.> It's worth noting that simply setting WASP_SERVER_URL alone isn't sufficient, as you've discovered. You need to set both the client and server environment variables to ensure proper communication between the front-end and back-end. If you're still having issues after trying this, you might want to check your firewall settings to ensure that the ports 3000 and 3001 are open for local network traffic. For more detailed information on configuring your Wasp app, you can refer to the Accessing the configuration documentation. Github Issue: Make it easy to use different ports (than 3000 and 3001) during Wasp development also discusses this topic and might provide additional context. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @cooluke., I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
AAA
AAAthis hour
When you run wasp start it gives you the network ip did you try using that?
miho
miho20h ago
GitHub
GitHub - wasp-lang/learning-materials: A place to collect some usef...
A place to collect some useful learning materials for Wasp - wasp-lang/learning-materials

Did you find this page helpful?