I recently deployed my next.js app to Digital Ocean, it’s working perfectly on my domain.bio, however, it wasn’t working on www.domain.bio. So what I did was, I inserted domain.bio as a domain on App Platform domains under my app, then inserted *.domain.bio, which looks like this now:
The problem is, now domain.bio and www.domain.bio are 2 separate websites and logging in one isn’t affecting the other (normally).
I tried to insert CNAME www on my digital ocean domains section, but it kept throwing 421 misdirected request (cloudflare) when I visited www.domain.bio. Currently, my domain DNS looks like this:
What can I do to redirect www.domain.bio to domain.bio?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hi there,
What I could suggest is to first decide whether you want to use
www.domain.bio
ordomain.bio
as your primary domain and then you’ll want to set up a server-side redirect from the non-preferred to the preferred version. This ensures that users and search engines always end up on the version of the site you’ve chosen.For Next.js deployed on DigitalOcean’s App Platform, you’d typically handle this in your app code using Next.js’s server-side capabilities or custom server logic.
Here’s an example using Next.js server-side logic:
Let me know how it goes!
Best,
Bobby