W
Wasp3w ago
Sven

Change server url

Hi how could i change the server url to which the client makes requests now? I setup a custom domain and want the client to use my custom server domain instead of the .fly.dev
4 Replies
kapa.ai
kapa.ai3w ago
Hi @Sven. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To change the server URL that the client uses to make requests after setting up a custom domain, you need to update the REACT_APP_API_URL environment variable when building your client. Here's how you can do it: 1. When building your client for production, set the REACT_APP_API_URL to your new custom domain. For example:
REACT_APP_API_URL=<https://your-custom-domain.com> npm run build
REACT_APP_API_URL=<https://your-custom-domain.com> npm run build
2. After deploying your client, make sure to update the WASP_WEB_CLIENT_URL environment variable on your server to reflect your new client URL. You can do this using the Fly.io CLI:
flyctl secrets set WASP_WEB_CLIENT_URL=<https://your-custom-client-domain.com>
flyctl secrets set WASP_WEB_CLIENT_URL=<https://your-custom-client-domain.com>
3. If you haven't already, you should also update the WASP_SERVER_URL on your server to reflect your new custom domain:
flyctl secrets set WASP_SERVER_URL=<https://your-custom-domain.com>
flyctl secrets set WASP_SERVER_URL=<https://your-custom-domain.com>
These steps will ensure that your client makes requests to your custom domain instead of the default .fly.dev domain. Deploying the Client (https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-the-client) provides more detailed information on building and deploying the client, including setting the REACT_APP_API_URL. Using a Custom Domain For Your App (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app) offers additional guidance on setting up custom domains with Fly.io. Remember to update your DNS records and configure your custom domain in Fly.io as described in the documentation to ensure everything works correctly with your new domain. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, 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?
Sven
SvenOP3w ago
@kapa.ai I am using fly, please explain again
kapa.ai
kapa.ai3w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Certainly! I apologize for any confusion. Since you're using Fly.io, let me explain the process specifically for that platform. When you set up a custom domain for your Wasp app on Fly.io, you need to update a few things to ensure the client makes requests to your custom server domain instead of the default .fly.dev domain. Here's the process: 1. First, set up your custom domain on Fly.io using the Wasp CLI:
wasp deploy fly cmd --context client certs create your-custom-domain.com
wasp deploy fly cmd --context client certs create your-custom-domain.com
Replace your-custom-domain.com with your actual domain name. 2. Add the DNS records as instructed by the output of the above command. 3. Update the WASP_WEB_CLIENT_URL environment variable on your server to use your custom domain:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://your-custom-domain.com>
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://your-custom-domain.com>
This step is crucial for keeping your CORS configuration up to date Using a Custom Domain For Your App (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app). 4. You should also update the WASP_SERVER_URL to reflect your new custom domain:
wasp deploy fly cmd --context server secrets set WASP_SERVER_URL=<https://your-custom-domain.com>
wasp deploy fly cmd --context server secrets set WASP_SERVER_URL=<https://your-custom-domain.com>
5. For the client-side, when you're building your web app for deployment, you need to set the REACT_APP_API_URL to your new custom domain:
REACT_APP_API_URL=<https://your-custom-domain.com> npm run build
REACT_APP_API_URL=<https://your-custom-domain.com> npm run build
This ensures that the client makes requests to your custom domain instead of the .fly.dev domain Client configuration object (https://wasp-lang.dev/docs/advanced/accessing-app-config#client-configuration-object). After completing these steps and redeploying your app, your client should now make requests to your custom domain instead of the .fly.dev domain. Remember to replace your-custom-domain.com with your actual custom domain in all the commands above. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, 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?
Sven
SvenOP3w ago
Tried to get help from kapa but for main issue please read from: https://discord.com/channels/686873244791210014/1311627403478700063/1312710512416522241
Want results from more Discord servers?
Add your server