Making sure www.<mysite>.com redirects to https://<mysite>.com?

@kapa.ai
This isn't really a wasp question as such (although it is a wasp app). I noticed my website only works with https:// in front and the www doesn't redirect after I deployed it on fly.io. What should I check to repair this?
2 Replies
kapa.ai
kapa.ai3mo ago
Hi @CamBlackwood. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To ensure that www.<mysite>.com redirects to <https://<mysite>.com,> you need to set up your DNS records correctly. Here are the steps you can follow: 1. Add your domain to your Fly client app by running the following command, replacing mycoolapp.com with your domain:
wasp deploy fly cmd --context client certs create mycoolapp.com
wasp deploy fly cmd --context client certs create mycoolapp.com
This command will output instructions to add the DNS records to your domain. 2. Add the DNS records for your domain. This will depend on your domain provider, but it should be a matter of adding an A record for @ and an AAAA record for @ with the values provided by the previous command. 3. Set your domain as the WASP_WEB_CLIENT_URL environment variable for your server app:
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>
This is necessary to keep your CORS configuration up to date. 4. If you want www.<mysite>.com to redirect to <mysite>.com, you need to set up a CNAME record for www that points to your domain. This is usually done through your domain provider's DNS settings. Remember to replace mycoolapp.com with your actual domain in all the commands. For more details, you can refer to the Wasp documentation on using a custom domain for your app (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app). If you've done all these and the issue persists, it might be a problem with the certificate. One user in the Wasp community solved a similar issue by removing the old certificate and creating a new one, then adding the proper DNS records according to the logs. You can find the details in this Discord support thread (https://discord.com/channels/686873244791210014/1201898985300971540). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @CamBlackwood, 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?
miho
miho3mo ago
I'd try to do this on the DNS level 🙂 if you are maybe using Cloudflare they have nice support for that: https://developers.cloudflare.com/rules/url-forwarding/examples/redirect-www-to-root/ Or at the app level in the client e.g. if the location is www.something.com then redirect 😄
Cloudflare Docs
Redirect from WWW to root | Cloudflare Rules docs
Create a redirect rule to forward HTTPS requests from the WWW subdomain to the root (also known as the “apex” or “naked” domain).
Want results from more Discord servers?
Add your server