W
Wasp-lang13mo ago
FanBoy

My browser is trying to make calls to localhost endpoints, despite the app being accessed remotely

I'm accessing the generated Node project in my browser from a remote server (e.g. http://192.168.7.2:3000/), but the app is trying to make calls to e.g. http://localhost:3001/auth/me which obviously isn't going to work
12 Replies
miho
miho13mo ago
I would direct you to the deployment docs https://wasp-lang.dev/docs/advanced/deployment/manually
Deploying Manually | Wasp
We'll cover how to deploy your Wasp app manually to a variety of providers:
FanBoy
FanBoy13mo ago
Hmm thank you, I don't quite understand that though. It's mentioning Dockerfile....I don't even have docker installed so it would be a miracle for this to somehow be running in a container. And fine I'll even play along and do export WASP_WEB_CLIENT_URL="http://192.168.7.2" but my webapp is still trying to make calls to localhost when I visit it remotely. I've also set the same thing in .env.server
miho
miho13mo ago
It depends how are you starting the app, it sounds to me that you started your project with wasp start? Which is a development command and we don't recommend using it for deployment
miho
miho13mo ago
When you are building the web app, you can set the REACT_APP_API_URL to your server URL -> https://wasp-lang.dev/docs/advanced/deployment/manually#3-deploying-the-web-client-frontend
Deploying Manually | Wasp
We'll cover how to deploy your Wasp app manually to a variety of providers:
FanBoy
FanBoy13mo ago
I'm not deploying anything, I'm literally trying wasp for the first time 🙂 even the wasp todo example does the same thing it says it's available at [Client] ? Local: http://localhost:3000/ [Client] ? Network: http://192.168.7.2:3000/ [Client] ? press h to show help but if you access via network, it's making calls to localhost
miho
miho13mo ago
I'm accessing the generated Node project in my browser from a remote server (e.g. http://192.168.7.2:3000/),
Yep, the setup is usually run locally so we assume localhost:3001 as your server URL If you have a different setup, the .env.client should work for you
miho
miho13mo ago
Env Variables | Wasp
Environment variables are used to configure projects based on the context in which they run. This allows them to exhibit different behaviors in different environments, such as development, staging, or production.
miho
miho13mo ago
There you can put REACT_APP_API_URL= http://192.168.7.2:3001
FanBoy
FanBoy13mo ago
NICE!
MEE6
MEE613mo ago
Wohooo @FanBoy, you just became a Waspeteer level 1!
FanBoy
FanBoy13mo ago
Thank you @miho ❤️
Filip
Filip13mo ago
Hey @FanBoy, a couple of corrections here.
I'm accessing the generated Node project in my browser from a remote server (e.g. http://192.168.7.2:3000/)
The address you've mentioned isn't an address of a remote server -it's your localhost address. In other words, localhost resolves to 192.168.7.2. It's just a shorter way to type the same thing.
the app is trying to make calls to e.g. http://localhost:3001/auth/me which obviously isn't going to work
Hm, this shouldn't be a problem. Everything should work without requiring you to set REACT_APP_API_URL= http://192.168.7.2:3001. Why do you think the request didn't work? I tried out the todo app locally and the app at http://192.168.7.2:3000/ is making requests to http://localhost:3001/auth/me without issues.
Want results from more Discord servers?
Add your server