Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).

appview/config: add TANGLED_DEV config

anirudh.fi 6d117f8c 74ac77e6

verified
+12 -4
+1
appview/config.go
··· 10 10 CookieSecret string `env:"TANGLED_COOKIE_SECRET, default=00000000000000000000000000000000"` 11 11 DbPath string `env:"TANGLED_DB_PATH, default=appview.db"` 12 12 ListenAddr string `env:"TANGLED_LISTEN_ADDR, default=0.0.0.0:3000"` 13 + Dev bool `env:"TANGLED_DEV, default=false"` 13 14 } 14 15 15 16 func LoadConfig(ctx context.Context) (*Config, error) {
+5 -3
appview/state/git_http.go
··· 14 14 knot := r.Context().Value("knot").(string) 15 15 repo := chi.URLParam(r, "repo") 16 16 17 - // TODO: make this https for production! 18 - targetURL := fmt.Sprintf("https://%s/%s/%s/info/refs?%s", knot, user.DID, repo, r.URL.RawQuery) 17 + uri := "https" 18 + if s.config.Dev { 19 + uri = "http" 20 + } 21 + targetURL := fmt.Sprintf("%s://%s/%s/%s/info/refs?%s", uri, knot, user.DID, repo, r.URL.RawQuery) 19 22 resp, err := http.Get(targetURL) 20 23 if err != nil { 21 24 http.Error(w, err.Error(), http.StatusInternalServerError) ··· 50 47 } 51 48 knot := r.Context().Value("knot").(string) 52 49 repo := chi.URLParam(r, "repo") 53 - // TODO: make this https for production! 54 50 targetURL := fmt.Sprintf("https://%s/%s/%s/git-upload-pack?%s", knot, user.DID, repo, r.URL.RawQuery) 55 51 client := &http.Client{} 56 52
+6 -1
appview/state/signer.go
··· 9 9 "fmt" 10 10 "net/http" 11 11 "net/url" 12 + "os" 12 13 "time" 13 14 ) 14 15 ··· 42 41 }, 43 42 } 44 43 45 - url, err := url.Parse(fmt.Sprintf("https://%s", domain)) 44 + uri := "https" 45 + if os.Getenv("TANGLED_DEV") == "true" { 46 + uri = "http" 47 + } 48 + url, err := url.Parse(fmt.Sprintf("%s://%s", uri, domain)) 46 49 if err != nil { 47 50 return nil, err 48 51 }