Fix problems with CORS and websocket allowed origins
This commit is contained in:
parent
0cd8dc2b5f
commit
e10844d32c
|
@ -16,7 +16,7 @@ func SetAccessControlHeaders(c *gin.Context) {
|
||||||
o := c.GetHeader("Origin")
|
o := c.GetHeader("Origin")
|
||||||
if o != config.Get().PanelLocation {
|
if o != config.Get().PanelLocation {
|
||||||
for _, origin := range config.Get().AllowedOrigins {
|
for _, origin := range config.Get().AllowedOrigins {
|
||||||
if o != origin {
|
if origin != "*" && o != origin {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,7 @@ func (h *Handler) ListenForExpiration(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listens for different events happening on a server and sends them along
|
var e = []string{
|
||||||
// to the connected websocket.
|
|
||||||
func (h *Handler) ListenForServerEvents(ctx context.Context) {
|
|
||||||
e := []string{
|
|
||||||
server.StatsEvent,
|
server.StatsEvent,
|
||||||
server.StatusEvent,
|
server.StatusEvent,
|
||||||
server.ConsoleOutputEvent,
|
server.ConsoleOutputEvent,
|
||||||
|
@ -50,6 +47,9 @@ func (h *Handler) ListenForServerEvents(ctx context.Context) {
|
||||||
server.BackupCompletedEvent,
|
server.BackupCompletedEvent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Listens for different events happening on a server and sends them along
|
||||||
|
// to the connected websocket.
|
||||||
|
func (h *Handler) ListenForServerEvents(ctx context.Context) {
|
||||||
eventChannel := make(chan events.Event)
|
eventChannel := make(chan events.Event)
|
||||||
for _, event := range e {
|
for _, event := range e {
|
||||||
h.server.Events().Subscribe(event, eventChannel)
|
h.server.Events().Subscribe(event, eventChannel)
|
||||||
|
|
|
@ -64,6 +64,10 @@ func GetHandler(s *server.Server, w http.ResponseWriter, r *http.Request) (*Hand
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, origin := range config.Get().AllowedOrigins {
|
for _, origin := range config.Get().AllowedOrigins {
|
||||||
|
if origin == "*" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if o != origin {
|
if o != origin {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user