socialnetworknews-api

git clone git://archive.git.mtrnord.blog/SocialNetworkNews/socialnetworknews-api.git
Log | Files | Refs | LICENSE

commit f6fb540600c8b11eb7121650def6de6b6f7f3723
parent ac6f8f330b51636e1d9cc6ddf356fb2aff78a055
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sat, 31 Mar 2018 21:31:44 +0200

Fix host header hopefully

Diffstat:
Mapi/login/twitter.go | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/api/login/twitter.go b/api/login/twitter.go @@ -150,7 +150,8 @@ func IssueSession() http.Handler { session.Save(w) w.Header().Set("Authorization", "Bearer "+tokenString) w.Header().Set("ID", twitterUser.IDStr) - domain := req.Header.Get("Host") + domain := req.Host + log.Println("domain:", domain) http.Redirect(w, req, domain, http.StatusFound) } return http.HandlerFunc(fn) @@ -179,9 +180,9 @@ func AuthRedirectHandler(config *oauth1.Config, failure http.Handler) http.Handl failure = gologin.DefaultFailureHandler } fn := func(w http.ResponseWriter, req *http.Request) { - domain := req.Header.Get("Host") - log.Println(domain) - config.CallbackURL = "https://" + domain + "/api/login/twitter/callback" + domain := req.Host + log.Println("domain:", domain) + config.CallbackURL = "https://" + domain + "/login/twitter/callback" TConfig = config ctx := req.Context() requestToken, _, err := libLogin.RequestTokenFromContext(ctx)