File tree 3 files changed +7
-1
lines changed
3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ require (
42
42
github.com/onsi/gomega v1.29.0 // indirect
43
43
github.com/pmezard/go-difflib v1.0.0 // indirect
44
44
github.com/rogpeppe/go-internal v1.11.0 // indirect
45
+ github.com/rs/cors v1.10.1 // indirect
45
46
github.com/samber/lo v1.38.1 // indirect
46
47
github.com/samber/slog-logrus v1.0.0 // indirect
47
48
github.com/spf13/pflag v1.0.5 // indirect
Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
87
87
github.com/rogpeppe/go-internal v1.9.0 /go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs =
88
88
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M =
89
89
github.com/rogpeppe/go-internal v1.11.0 /go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA =
90
+ github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo =
91
+ github.com/rs/cors v1.10.1 /go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU =
90
92
github.com/russross/blackfriday/v2 v2.1.0 /go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM =
91
93
github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM =
92
94
github.com/samber/lo v1.38.1 /go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA =
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
20
20
"github.com/acorn-io/gptscript/pkg/runner"
21
21
"github.com/acorn-io/gptscript/pkg/types"
22
22
"github.com/olahol/melody"
23
+ "github.com/rs/cors"
23
24
)
24
25
25
26
type Options struct {
@@ -170,12 +171,14 @@ func (s *Server) Start(ctx context.Context) error {
170
171
s .melody .HandleConnect (s .Connect )
171
172
go s .events .Start (ctx )
172
173
log .Infof ("Listening on http://%s" , s .listenAddress )
173
- server := & http.Server {Addr : s .listenAddress , Handler : s }
174
+ handler := cors .Default ().Handler (s )
175
+ server := & http.Server {Addr : s .listenAddress , Handler : handler }
174
176
context .AfterFunc (ctx , func () {
175
177
ctx , cancel := context .WithTimeout (context .Background (), 15 * time .Second )
176
178
defer cancel ()
177
179
_ = server .Shutdown (ctx )
178
180
})
181
+
179
182
return server .ListenAndServe ()
180
183
}
181
184
You can’t perform that action at this time.
0 commit comments