Skip to content
This repository was archived by the owner on Jul 1, 2021. It is now read-only.

Commit 411b0c1

Browse files
committed
- added the ability to disable origin check for local envs
1 parent 0a364da commit 411b0c1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

config.go

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ type Config struct {
77
// Path defines on this URL the middleware must be activated. Same path must
88
// be handled by underlying application kernel to authorize the consumption.
99
Path string
10+
11+
// NoOrigin disables origin check, only for debug.
12+
NoOrigin bool
1013
}
1114

1215
// Hydrate reads the configuration values from the source configuration.

service.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (s *Service) AddListener(l func(event int, ctx interface{})) {
3636
func (s *Service) Init(
3737
cfg *Config,
3838
env env.Environment,
39-
http *rhttp.Service,
39+
rttp *rhttp.Service,
4040
rpc *rpc.Service,
4141
broadcast *broadcast.Service,
4242
) (bool, error) {
@@ -61,7 +61,14 @@ func (s *Service) Init(
6161

6262
// init all this stuff
6363
s.upgrade = websocket.Upgrader{}
64-
http.AddMiddleware(s.middleware)
64+
65+
if s.cfg.NoOrigin {
66+
s.upgrade.CheckOrigin = func(r *http.Request) bool {
67+
return true
68+
}
69+
}
70+
71+
rttp.AddMiddleware(s.middleware)
6572

6673
return true, nil
6774
}

0 commit comments

Comments
 (0)