W
Wasp-lang•2mo ago
josh

Server URL is incorrect when deployed

Hi guys, so after trying to deploy my app, adding my domain, various deployments, restarts etc I finally got it deployed. The client and server are both running. However, the client cannot make requests to the server. The client is making requests to a hostname which doesn't exist (https://frosty-pond-etc instead of https://autumn-pine-etc). I tried checking the toml file on the server, the name is correct. I tried setting it up like REACT_APP_API_URL=https:/autumn-pine-etc wasp deploy fly dep loy But it wont update. Driving me crazy. Where can I configure the server base URL that the client is calling when deployed on fly.io. Thanks guys!
9 Replies
kapa.ai
kapa.ai•2mo ago
Hi @josh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The server URL that your client is calling is set by the REACT_APP_API_URL environment variable. This variable should contain the value of your server's URL as the user's browser sees it, with the DNS and proxies considered source (https://wasp-lang.dev/docs/advanced/accessing-app-config#client-configuration-object). You can access it in your code like this:
import { config } from 'wasp/client'

console.log(config.apiUrl)
import { config } from 'wasp/client'

console.log(config.apiUrl)
If you're using a custom domain, you need to set your domain as the WASP_WEB_CLIENT_URL environment variable for your server app. This is done to keep your CORS configuration up to date source (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app). Here's how you can do it:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://mycoolapp.com>
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://mycoolapp.com>
Make sure to replace mycoolapp.com with your domain. Also, ensure that the REACT_APP_API_URL and WASP_WEB_CLIENT_URL environment variables are valid URLs. Wasp should check whether they specified a valid, absolute URL source (https://github.com/wasp-lang/wasp/issues/756). If you're still having issues, it might be worth checking the logs and secrets on your Fly.io app. You can do this with the following commands:
flyctl logs
flyctl secrets list
flyctl logs
flyctl secrets list
source (https://wasp-lang.dev/docs/advanced/deployment/manually#deploy-to-a-flyio-app) If you're still having trouble, please provide more details about the error messages you're seeing, and we can try to help you troubleshoot further. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @josh, 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?
josh
josh•2mo ago
Tried this! Just tried npm install && REACT_APP_API_URL=https://my-wasp-app-server-autumn-pine-3967.fly.dev npm run build Then wasp deploy fly deploy Still querying the old, non existent server url
MEE6
MEE6•2mo ago
Wohooo @josh, you just became a Waspeteer level 1!
miho
miho•2mo ago
I'd recommend nuking the deployment - delete the apps, and try redeploying. Make sure that the name of the app doesn't exist already on Fly! Wasp CLI doesn't currently check if an app name is taken, and this results in Fly CLI choosing a random name for you which messes up the Wasp deployment process.
josh
josh•2mo ago
Okay I'll try that. Even for the initial launch deploy, I get problems with the naming
josh
josh•2mo ago
No description
josh
josh•2mo ago
I can change the name to the correct one and rerun the attach command But then what should I do? Run wasp deploy fly deploy again?
miho
miho•2mo ago
Rerun the deployment process from scratch: delete the TOML files, delete the Fly apps in their dashboard. Choose a name that's not taken and try again 🙂
josh
josh•2mo ago
Okay, thanks!
Want results from more Discord servers?
Add your server