How do I create my own domain alias on a Go server?
I have a web application running on top of Go. Let's say this is a web application running on domain.com
, each user can create them in a page with a custom pallet for example user.domain.com
.
Some of my users want to add their own domain, for example: userdomain.org
or page.anotherdomain.com
. How to do it?
I already search on google, they should add an alias CNAME
, but it showedDNS Resolution Error
source to share
Ask the user to add their domain to your application and then in your http handler check if the req.Host
known custom page matches .
func handleUserPage(w http.ResponseWriter, r *http.Request) {
user, err := db.FindUserByDomain(r.Host)
if err != nil {
w.WriteStatus(404)
return
}
//display user page based on r.URL.Path maybe?
}
source to share