From 494319804a7bfc6a32ad3ac1ceefa2f5e5a4dbcb Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Thu, 15 Feb 2018 08:10:15 +0000 Subject: [PATCH 01/10] config and stability, scan every 10 seconds forever --- cfg/wificfg.json | 2 +- iotwifi/commands.go | 33 +++++---------------------------- iotwifi/iotwifi.go | 25 +++++++++++++++++++------ iotwifi/wpacfg.go | 23 ++++++++++++++++------- main.go | 4 ++-- 5 files changed, 43 insertions(+), 44 deletions(-) diff --git a/cfg/wificfg.json b/cfg/wificfg.json index 985869b..984194a 100644 --- a/cfg/wificfg.json +++ b/cfg/wificfg.json @@ -6,7 +6,7 @@ }, "host_apd_cfg": { "ip": "192.168.27.1", - "ssid": "iot-wifi", + "ssid": "iot-wifi-cfg", "wpa_passphrase":"iotwifipass", "channel": "6" }, diff --git a/iotwifi/commands.go b/iotwifi/commands.go index b54185b..460f236 100644 --- a/iotwifi/commands.go +++ b/iotwifi/commands.go @@ -45,6 +45,9 @@ func (c *Command) RemoveApInterface() { // ConfigureApInterface func (c *Command) ConfigureApInterface() { + c.Log.Info("GOt HERE %s", c.SetupCfg.HostApdCfg.Ip) + + cmd := exec.Command("ifconfig", "uap0", c.SetupCfg.HostApdCfg.Ip) cmd.Start() cmd.Wait() @@ -72,11 +75,12 @@ func (c *Command) CheckApInterface() { // StartWpaSupplicant func (c *Command) StartWpaSupplicant() { + args := []string{ "-d", "-Dnl80211", "-iwlan0", - "-c" + c.SetupCfg.WpaSupplicantCfg.CfgFile, + "-c/etc/wpa_supplicant/wpa_supplicant.conf", } cmd := exec.Command("wpa_supplicant", args...) @@ -101,30 +105,3 @@ func (c *Command) StartDnsmasq() { cmd := exec.Command("dnsmasq", args...) go c.Runner.ProcessCmd("dnsmasq", cmd) } - -// StartHostapd -func (c *Command) StartHostapd() { - - c.Runner.Log.Info("Starting hostapd.") - - cmd := exec.Command("hostapd", "-d", "/dev/stdin") - hostapdPipe, _ := cmd.StdinPipe() - c.Runner.ProcessCmd("hostapd", cmd) - - cfg := `interface=uap0 -ssid=` + c.SetupCfg.HostApdCfg.Ssid + ` -hw_mode=g -channel=` + c.SetupCfg.HostApdCfg.Channel + ` -macaddr_acl=0 -auth_algs=1 -ignore_broadcast_ssid=0 -wpa=2 -wpa_passphrase=` + c.SetupCfg.HostApdCfg.WpaPassphrase + ` -wpa_key_mgmt=WPA-PSK -wpa_pairwise=TKIP -rsn_pairwise=CCMP` - - hostapdPipe.Write([]byte(cfg)) - hostapdPipe.Close() - -} diff --git a/iotwifi/iotwifi.go b/iotwifi/iotwifi.go index a43eb1e..a5dc3b8 100644 --- a/iotwifi/iotwifi.go +++ b/iotwifi/iotwifi.go @@ -34,8 +34,8 @@ type CmdMessage struct { Stdin *io.WriteCloser } -func loadCfg() (*SetupCfg, error) { - fileData, err := ioutil.ReadFile("./cfg/wificfg.json") +func loadCfg(cfgLocation string) (*SetupCfg, error) { + fileData, err := ioutil.ReadFile(cfgLocation) if err != nil { panic(err) } @@ -48,7 +48,7 @@ func loadCfg() (*SetupCfg, error) { } // RunWifi starts AP and Station -func RunWifi(log bunyan.Logger, messages chan CmdMessage) { +func RunWifi(log bunyan.Logger, messages chan CmdMessage, cfgLocation string) { log.Info("Loading IoT Wifi...") @@ -59,7 +59,7 @@ func RunWifi(log bunyan.Logger, messages chan CmdMessage) { Commands: make(map[string]*exec.Cmd, 0), } - setupCfg, err := loadCfg() + setupCfg, err := loadCfg(cfgLocation) if err != nil { log.Error("Could not load config: %s", err.Error()) return @@ -77,14 +77,27 @@ func RunWifi(log bunyan.Logger, messages chan CmdMessage) { os.Exit(1) }) - wpacfg := NewWpaCfg(log) - wpacfg.StartAP() + wpacfg := NewWpaCfg(log, cfgLocation) + wpacfg.StartAP() + time.Sleep(10 * time.Second) command.StartWpaSupplicant() + + // Scan + time.Sleep(5 * time.Second) + wpacfg.ScanNetworks() + command.StartDnsmasq() + go func() { + for { + wpacfg.ScanNetworks() + time.Sleep(10 * time.Second) + } + }() + // staticFields for logger staticFields := make(map[string]interface{}) diff --git a/iotwifi/wpacfg.go b/iotwifi/wpacfg.go index 0cc58d7..58662cc 100644 --- a/iotwifi/wpacfg.go +++ b/iotwifi/wpacfg.go @@ -15,6 +15,7 @@ import ( type WpaCfg struct { Log bunyan.Logger WpaCmd []string + WpaCfg *SetupCfg } type WpaNetwork struct { @@ -37,10 +38,17 @@ type WpaConnection struct { Message string `json:"message"` } -func NewWpaCfg(log bunyan.Logger) *WpaCfg { +func NewWpaCfg(log bunyan.Logger, cfgLocation string) *WpaCfg { + + setupCfg, err := loadCfg(cfgLocation) + if err != nil { + log.Error("Could not load config: %s", err.Error()) + panic(err) + } return &WpaCfg{ Log: log, + WpaCfg: setupCfg, } } @@ -49,7 +57,8 @@ func (wpa *WpaCfg) StartAP() { wpa.Log.Info("Starting Hostapd.") command := &Command{ - Log: wpa.Log, + Log: wpa.Log, + SetupCfg: wpa.WpaCfg, } command.RemoveApInterface() @@ -71,25 +80,25 @@ func (wpa *WpaCfg) StartAP() { stdOutScanner := bufio.NewScanner(cmdStdoutReader) go func() { for stdOutScanner.Scan() { - wpa.Log.Info("GOT: %s", stdOutScanner.Text()) + wpa.Log.Info("HOSTAPD GOT: %s", stdOutScanner.Text()) messages <- stdOutScanner.Text() } }() cfg := `interface=uap0 -ssid=iotwifi2 +ssid=` + wpa.WpaCfg.HostApdCfg.Ssid + ` hw_mode=g -channel=6 +channel=` + wpa.WpaCfg.HostApdCfg.Channel + ` macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 -wpa_passphrase=iotwifipass +wpa_passphrase=` + wpa.WpaCfg.HostApdCfg.WpaPassphrase + ` wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP` - + wpa.Log.Info("Hostapd CFG: %s", cfg) hostapdPipe.Write([]byte(cfg)) cmd.Start() diff --git a/main.go b/main.go index e4b8fa0..4870afb 100644 --- a/main.go +++ b/main.go @@ -37,9 +37,9 @@ func main() { messages := make(chan iotwifi.CmdMessage, 1) - go iotwifi.RunWifi(blog, messages) + go iotwifi.RunWifi(blog, messages, "./cfg/wificfg.json") - wpacfg := iotwifi.NewWpaCfg(blog) + wpacfg := iotwifi.NewWpaCfg(blog, "./cfg/wificfg.json") apiPayloadReturn := func(w http.ResponseWriter, message string, payload interface{}) { apiReturn := &ApiReturn{ From d1475baaf16f29a5ec9528e28d42d8b9f9011519 Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Thu, 15 Feb 2018 16:36:31 +0000 Subject: [PATCH 02/10] scan every 30 seconds --- iotwifi/iotwifi.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iotwifi/iotwifi.go b/iotwifi/iotwifi.go index a5dc3b8..940f84a 100644 --- a/iotwifi/iotwifi.go +++ b/iotwifi/iotwifi.go @@ -94,7 +94,7 @@ func RunWifi(log bunyan.Logger, messages chan CmdMessage, cfgLocation string) { go func() { for { wpacfg.ScanNetworks() - time.Sleep(10 * time.Second) + time.Sleep(30 * time.Second) } }() From 0284c67a9e4b67f0a7ed6bdb7755872168d43779 Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Thu, 15 Feb 2018 17:52:33 +0000 Subject: [PATCH 03/10] cfg location from env or fallback --- cfg/wificfg.json | 2 +- iotwifi/iotwifi.go | 37 ++++++++++++++++++++++++++++++++----- main.go | 27 +++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/cfg/wificfg.json b/cfg/wificfg.json index 984194a..af1d97a 100644 --- a/cfg/wificfg.json +++ b/cfg/wificfg.json @@ -6,7 +6,7 @@ }, "host_apd_cfg": { "ip": "192.168.27.1", - "ssid": "iot-wifi-cfg", + "ssid": "iot-wifi-cfg-3", "wpa_passphrase":"iotwifipass", "channel": "6" }, diff --git a/iotwifi/iotwifi.go b/iotwifi/iotwifi.go index 940f84a..cd4af57 100644 --- a/iotwifi/iotwifi.go +++ b/iotwifi/iotwifi.go @@ -12,6 +12,8 @@ import ( "os" "os/exec" "time" + "net/http" + "regexp" "github.com/bhoriuchi/go-bunyan/bunyan" ) @@ -35,14 +37,39 @@ type CmdMessage struct { } func loadCfg(cfgLocation string) (*SetupCfg, error) { - fileData, err := ioutil.ReadFile(cfgLocation) - if err != nil { - panic(err) - } v := &SetupCfg{} + var jsonData []byte + + urlDelimR, _ := regexp.Compile("://") + isUrl := urlDelimR.Match([]byte(cfgLocation)) + + // if not a url + if !isUrl { + fileData, err := ioutil.ReadFile(cfgLocation) + if err != nil { + panic(err) + } + jsonData = fileData + } + + if isUrl { + res, err := http.Get(cfgLocation) + if err != nil { + panic(err) + } + + defer res.Body.Close() + + urlData, err := ioutil.ReadAll(res.Body) + if err != nil { + panic(err) + } + + jsonData = urlData + } - err = json.Unmarshal(fileData, v) + err := json.Unmarshal(jsonData, v) return v, err } diff --git a/main.go b/main.go index 4870afb..84c72f8 100644 --- a/main.go +++ b/main.go @@ -37,9 +37,10 @@ func main() { messages := make(chan iotwifi.CmdMessage, 1) - go iotwifi.RunWifi(blog, messages, "./cfg/wificfg.json") + cfgUrl := setEnvIfEmpty("IOTWIFI_CFG", "cfg/wificfg.json") - wpacfg := iotwifi.NewWpaCfg(blog, "./cfg/wificfg.json") + go iotwifi.RunWifi(blog, messages, cfgUrl) + wpacfg := iotwifi.NewWpaCfg(blog, cfgUrl) apiPayloadReturn := func(w http.ResponseWriter, message string, payload interface{}) { apiReturn := &ApiReturn{ @@ -91,7 +92,6 @@ func main() { status, err := wpacfg.Status() if err != nil { - //http.Error(w, err.Error(), http.StatusInternalServerError) blog.Error(err.Error()) return } @@ -108,7 +108,6 @@ func main() { connection, err := wpacfg.ConnectNetwork(creds) if err != nil { - //http.Error(w, err.Error(), http.StatusInternalServerError) blog.Error(err.Error()) return } @@ -214,3 +213,23 @@ func main() { http.ListenAndServe(":8080", nil) } + +// getEnv gets an environment variable or sets a default if +// one does not exist. +func getEnv(key, fallback string) string { + value := os.Getenv(key) + if len(value) == 0 { + return fallback + } + + return value +} + +// setEnvIfEmp Date: Thu, 15 Feb 2018 18:07:16 +0000 Subject: [PATCH 04/10] borke out types for external use --- iotwifi/commands.go | 26 -------------------------- iotwifi/types.go | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 26 deletions(-) create mode 100644 iotwifi/types.go diff --git a/iotwifi/commands.go b/iotwifi/commands.go index 460f236..f34ed95 100644 --- a/iotwifi/commands.go +++ b/iotwifi/commands.go @@ -6,29 +6,6 @@ import ( "github.com/bhoriuchi/go-bunyan/bunyan" ) -type SetupCfg struct { - DnsmasqCfg DnsmasqCfg `json:"dnsmasq_cfg"` - HostApdCfg HostApdCfg `json:"host_apd_cfg"` - WpaSupplicantCfg WpaSupplicantCfg `json:"wpa_supplicant_cfg"` -} - -type DnsmasqCfg struct { - Address string `json:"address"` // --address=/#/192.168.27.1", - DhcpRange string `json:"dhcp_range"` // "--dhcp-range=192.168.27.100,192.168.27.150,1h", - VendorClass string `json:"vendor_class"` // "--dhcp-vendorclass=set:device,IoT", -} - -type HostApdCfg struct { - Ssid string `json:"ssid"` // ssid=iotwifi2 - WpaPassphrase string `json:"wpa_passphrase"` // wpa_passphrase=iotwifipass - Channel string `json:"channel"` // channel=6 - Ip string `json:"ip"` // 192.168.27.1 -} - -type WpaSupplicantCfg struct { - CfgFile string `json:"cfg_file"` // /etc/wpa_supplicant/wpa_supplicant.conf -} - // Command for device network commands type Command struct { Log bunyan.Logger @@ -45,9 +22,6 @@ func (c *Command) RemoveApInterface() { // ConfigureApInterface func (c *Command) ConfigureApInterface() { - c.Log.Info("GOt HERE %s", c.SetupCfg.HostApdCfg.Ip) - - cmd := exec.Command("ifconfig", "uap0", c.SetupCfg.HostApdCfg.Ip) cmd.Start() cmd.Wait() diff --git a/iotwifi/types.go b/iotwifi/types.go new file mode 100644 index 0000000..415960c --- /dev/null +++ b/iotwifi/types.go @@ -0,0 +1,25 @@ +package iotwifi + +type SetupCfg struct { + DnsmasqCfg DnsmasqCfg `json:"dnsmasq_cfg"` + HostApdCfg HostApdCfg `json:"host_apd_cfg"` + WpaSupplicantCfg WpaSupplicantCfg `json:"wpa_supplicant_cfg"` +} + +type DnsmasqCfg struct { + Address string `json:"address"` // --address=/#/192.168.27.1", + DhcpRange string `json:"dhcp_range"` // "--dhcp-range=192.168.27.100,192.168.27.150,1h", + VendorClass string `json:"vendor_class"` // "--dhcp-vendorclass=set:device,IoT", +} + +type HostApdCfg struct { + Ssid string `json:"ssid"` // ssid=iotwifi2 + WpaPassphrase string `json:"wpa_passphrase"` // wpa_passphrase=iotwifipass + Channel string `json:"channel"` // channel=6 + Ip string `json:"ip"` // 192.168.27.1 +} + +type WpaSupplicantCfg struct { + CfgFile string `json:"cfg_file"` // /etc/wpa_supplicant/wpa_supplicant.conf +} + From c97eca1c874070a369cad3c07ccce7bee0a63350 Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Thu, 15 Feb 2018 20:48:26 +0000 Subject: [PATCH 05/10] dockerfile --- Dockerfile | 27 +++++++++++++++++++++++++++ dev/Dockerfile | 1 - 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..da1d2b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM arm32v7/golang:1.9 AS builder + +ENV GOPATH /go +WORKDIR /go/src + +RUN go get github.com/bhoriuchi/go-bunyan/bunyan +RUN go get github.com/gorilla/mux + +RUN mkdir -p /go/src/github.com/cjimti/iotwifi +COPY . /go/src/github.com/cjimti/iotwifi + +RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o /go/bin/wifi /go/src/github.com/cjimti/iotwifi/main.go + +FROM arm32v6/alpine + +RUN apk update +RUN apk add bridge hostapd wireless-tools wpa_supplicant dnsmasq iw + +RUN mkdir -p /etc/wpa_supplicant/ +COPY ./dev/configs/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf + +WORKDIR / + +COPY --from=builder /go/bin/wifi /wifi +ENTRYPOINT ["/wifi"] + + diff --git a/dev/Dockerfile b/dev/Dockerfile index 002c473..68a387e 100644 --- a/dev/Dockerfile +++ b/dev/Dockerfile @@ -12,5 +12,4 @@ ENV GOPATH /go WORKDIR /go/src RUN go get github.com/bhoriuchi/go-bunyan/bunyan -RUN go get github.com/ThomasRooney/gexpect RUN go get github.com/gorilla/mux From e6c19e87a1dfa355ac92a7eb11d169d6c0d9ec94 Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Thu, 15 Feb 2018 21:53:33 +0000 Subject: [PATCH 06/10] IOTWIFI_PORT to specify http port --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 84c72f8..925a690 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,7 @@ func main() { messages := make(chan iotwifi.CmdMessage, 1) cfgUrl := setEnvIfEmpty("IOTWIFI_CFG", "cfg/wificfg.json") + port := setEnvIfEmpty("IOTWIFI_PORT", "8080") go iotwifi.RunWifi(blog, messages, cfgUrl) wpacfg := iotwifi.NewWpaCfg(blog, cfgUrl) @@ -209,8 +210,8 @@ func main() { http.Handle("/", r) // serve http - blog.Info("HTTP Listening on 8080") - http.ListenAndServe(":8080", nil) + blog.Info("HTTP Listening on " + port) + http.ListenAndServe(":" + port, nil) } From 61505747c29b922f976d27738c9fa735d7641bb7 Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Fri, 16 Feb 2018 05:05:26 +0000 Subject: [PATCH 07/10] added CORS support --- Dockerfile | 1 + Makefile | 10 +++++++++- dev/Dockerfile | 1 + main.go | 4 +++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index da1d2b4..26378c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ WORKDIR /go/src RUN go get github.com/bhoriuchi/go-bunyan/bunyan RUN go get github.com/gorilla/mux +RUN go get github.com/gorilla/handlers RUN mkdir -p /go/src/github.com/cjimti/iotwifi COPY . /go/src/github.com/cjimti/iotwifi diff --git a/Makefile b/Makefile index 5daef2e..58585ea 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,16 @@ -IMAGE ?= iotwifi +IMAGE ?= cjimti/iotwifi:armhf-1.0.1 NAME ?= iotwifi +all: build push + dev: dev_build dev_run +build: + docker build -t $(IMAGE) . + +push: + docker push $(IMAGE) + dev_build: docker build -t $(IMAGE) ./dev/ diff --git a/dev/Dockerfile b/dev/Dockerfile index 68a387e..79dce66 100644 --- a/dev/Dockerfile +++ b/dev/Dockerfile @@ -13,3 +13,4 @@ WORKDIR /go/src RUN go get github.com/bhoriuchi/go-bunyan/bunyan RUN go get github.com/gorilla/mux +RUN go get github.com/gorilla/handlers diff --git a/main.go b/main.go index 925a690..c1defb9 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "github.com/bhoriuchi/go-bunyan/bunyan" "github.com/cjimti/iotwifi/iotwifi" "github.com/gorilla/mux" + "github.com/gorilla/handlers" ) type ApiReturn struct { @@ -201,6 +202,7 @@ func main() { r := mux.NewRouter() r.Use(allowHeaders) r.Use(logHandler) + // set app routes r.HandleFunc("/status", statusHandler) @@ -211,7 +213,7 @@ func main() { // serve http blog.Info("HTTP Listening on " + port) - http.ListenAndServe(":" + port, nil) + http.ListenAndServe(":" + port, handlers.CORS()(r)) } From 78f9e546046e035e9f02b4cd5f6d67c095354c8f Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Fri, 16 Feb 2018 05:30:01 +0000 Subject: [PATCH 08/10] better CORS --- main.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index c1defb9..539742e 100644 --- a/main.go +++ b/main.go @@ -173,18 +173,6 @@ func main() { w.Write(ret) } - // api headers for csx allowance - allowHeaders := func(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - - w.Header().Set("Access-Control-Allow-Origin", "*") - w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization, Content-Length, X-Requested-With, Accept, Origin") - w.Header().Set("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS") - - next.ServeHTTP(w, r) - }) - } - // common log middleware for api logHandler := func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -200,20 +188,24 @@ func main() { // setup router and middleware r := mux.NewRouter() - r.Use(allowHeaders) r.Use(logHandler) // set app routes r.HandleFunc("/status", statusHandler) - r.HandleFunc("/connect", connectHandler) + r.HandleFunc("/connect", connectHandler).Methods("POST") r.HandleFunc("/scan", scanHandler) r.HandleFunc("/kill", killHandler) http.Handle("/", r) + // CORS + headersOk := handlers.AllowedHeaders([]string{"Content-Type","Authorization","Content-Length","X-Requested-With","Accept","Origin"}) + originsOk := handlers.AllowedOrigins([]string{os.Getenv("ORIGIN_ALLOWED")}) + methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS","DELETE"}) + // serve http blog.Info("HTTP Listening on " + port) - http.ListenAndServe(":" + port, handlers.CORS()(r)) + http.ListenAndServe(":" + port, handlers.CORS(originsOk,headersOk,methodsOk)(r)) } From dea6904c04d41bdd1119976aafe217833f96f939 Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Fri, 16 Feb 2018 05:32:07 +0000 Subject: [PATCH 09/10] make update --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 58585ea..d265991 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -IMAGE ?= cjimti/iotwifi:armhf-1.0.1 +IMAGE ?= cjimti/iotwifi NAME ?= iotwifi all: build push From b38449909667233e0d442a5807826e109bded8ec Mon Sep 17 00:00:00 2001 From: Craig Johnston Date: Fri, 16 Feb 2018 06:43:07 +0000 Subject: [PATCH 10/10] fixed CORS origin --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 539742e..7aca37f 100644 --- a/main.go +++ b/main.go @@ -200,7 +200,7 @@ func main() { // CORS headersOk := handlers.AllowedHeaders([]string{"Content-Type","Authorization","Content-Length","X-Requested-With","Accept","Origin"}) - originsOk := handlers.AllowedOrigins([]string{os.Getenv("ORIGIN_ALLOWED")}) + originsOk := handlers.AllowedOrigins([]string{"*"}) methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS","DELETE"}) // serve http