Skip to content

Commit

Permalink
GH-181: Added Access-Control-Allow-Credentials header in response to …
Browse files Browse the repository at this point in the history
…HTTP requests
  • Loading branch information
jirenius committed Feb 3, 2021
1 parent 8ad9435 commit f27b6bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions server/apiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func (s *Service) initAPIHandler() error {
// setCommonHeaders sets common headers such as Access-Control-*.
// It returns error if the origin header does not match any allowed origin.
func (s *Service) setCommonHeaders(w http.ResponseWriter, r *http.Request) error {
if s.cfg.HeaderAuth != nil {
w.Header().Set("Access-Control-Allow-Credentials", "true")
}
if s.cfg.allowOrigin[0] == "*" {
w.Header().Set("Access-Control-Allow-Origin", "*")
return nil
Expand Down
4 changes: 1 addition & 3 deletions server/wsConn.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ func (s *Service) newWSConn(ws *websocket.Conn, request *http.Request, protocol
return nil
}

cid := xid.New()

conn := &wsConn{
cid: cid.String(),
cid: xid.New().String(),
ws: ws,
request: request,
serv: s,
Expand Down

0 comments on commit f27b6bb

Please sign in to comment.