mirror of
https://github.com/balzack/databag.git
synced 2025-04-21 17:15:16 +00:00
allowing cross origin websocket in dev mode
This commit is contained in:
parent
42c9546efd
commit
f5a38c03fd
@ -23,6 +23,13 @@ func Status(w http.ResponseWriter, r *http.Request) {
|
||||
// send ringing updates
|
||||
ringMode := r.FormValue("mode") == "ring"
|
||||
|
||||
// allows cross origin websocket in dev mode
|
||||
if APPMode == "dev" {
|
||||
upgrader.CheckOrigin = func(r *http.Request) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// accept websocket connection
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
|
@ -1,5 +1,8 @@
|
||||
package databag
|
||||
|
||||
//APPMode for development mode
|
||||
var APPMode = "prod"
|
||||
|
||||
//APPCopyTransform reserved tranform code indicating copy
|
||||
const APPTransformCopy = "_"
|
||||
|
||||
|
@ -79,6 +79,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
app.APPMode = mode
|
||||
router := app.NewRouter(webApp)
|
||||
origins := handlers.AllowedOrigins([]string{"*"})
|
||||
headers := handlers.AllowedHeaders([]string{"content-type", "authorization"})
|
||||
|
Loading…
x
Reference in New Issue
Block a user