# Brand Domain Usage
This guide shows you how to use your own domain while sharing deeplinks for stories.
Before you begin
You need to handle deeplinks in your application as described in Deeplinks for Stories
Normally, when you get the deeplinks from Storyly Dashboard -> Settings -> App Settings (opens new window), they are in this format: https://open.storyly.io/share/v2/{story_id}
.
With following methods, you can use your own domain while sharing a deeplink in this format: https://example.com?id={story_id}
.
Here are two methods to handle this on your backend:
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
)
func ReProxy(remote *url.URL, p *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
storyID := r.URL.Query().Get("id")
if storyID == "" {
http.NotFound(w, r)
} else {
r.Host = remote.Host
r.URL.Path = fmt.Sprintf("/share/v2/%s", storyID)
p.ServeHTTP(w, r)
}
}
}
func main() {
remote, err := url.Parse("https://open.storyly.io")
if err != nil {
panic(err)
}
proxy := httputil.NewSingleHostReverseProxy(remote)
http.HandleFunc("/", ReProxy(remote, proxy))
if err := http.ListenAndServe(":9090", nil); err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
package main
import (
"fmt"
"log"
"net/http"
)
func Redirect(w http.ResponseWriter, r *http.Request) {
storyID := r.URL.Query().Get("id")
if storyID == "" {
http.NotFound(w, r)
} else {
redirectionURL := fmt.Sprintf("https://open.storyly.io/share/v2/%s", storyID)
http.Redirect(w, r, redirectionURL, 302)
}
}
func main() {
http.HandleFunc("/", Redirect)
if err := http.ListenAndServe(":9090", nil); err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
WARNING
Make sure that your URL includes {story_id}
as variable to indicate shared story, Storyly SDK will automatically replaces this. Moreover, do not forget the replace it in your backend with correct parameter as shown in samples.
After handling brand domain usage in your backend, you can use the following function in the initialization process:
storylyView.storylyShareUrl = String?