mirror of
https://github.com/balzack/databag.git
synced 2025-03-13 00:50:03 +00:00
updating cors to work with local dev webapp servers
Some checks failed
CI / CI (push) Has been cancelled
Some checks failed
CI / CI (push) Has been cancelled
This commit is contained in:
parent
63611f2a6e
commit
b025061682
@ -23,6 +23,11 @@ func Status(w http.ResponseWriter, r *http.Request) {
|
||||
// send ringing updates
|
||||
ringMode := r.FormValue("mode") == "ring"
|
||||
|
||||
// allows cross origin websocket in dev mode
|
||||
upgrader.CheckOrigin = func(r *http.Request) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// accept websocket connection
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
|
@ -78,13 +78,14 @@ func main() {
|
||||
|
||||
router := app.NewRouter(webApp)
|
||||
origins := handlers.AllowedOrigins([]string{"*"})
|
||||
headers := handlers.AllowedHeaders([]string{"content-type", "authorization", "credentials"})
|
||||
methods := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"})
|
||||
|
||||
if cert != "" && key != "" {
|
||||
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:] + " -c " + cert + " -k " + key + " -t " + transformPath)
|
||||
log.Fatal(http.ListenAndServeTLS(port, cert, key, handlers.CORS(origins, methods)(router)))
|
||||
log.Fatal(http.ListenAndServeTLS(port, cert, key, handlers.CORS(origins, headers, methods)(router)))
|
||||
} else {
|
||||
log.Printf("using args:" + " -s " + storePath + " -w " + webApp + " -p " + port[1:] + " -t " + transformPath)
|
||||
log.Fatal(http.ListenAndServe(port, handlers.CORS(origins, methods)(router)))
|
||||
log.Fatal(http.ListenAndServe(port, handlers.CORS(origins, headers, methods)(router)))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user