File tree Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ require (
4242 github.com/onsi/gomega v1.29.0 // indirect
4343 github.com/pmezard/go-difflib v1.0.0 // indirect
4444 github.com/rogpeppe/go-internal v1.11.0 // indirect
45+ github.com/rs/cors v1.10.1 // indirect
4546 github.com/samber/lo v1.38.1 // indirect
4647 github.com/samber/slog-logrus v1.0.0 // indirect
4748 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
8787github.com/rogpeppe/go-internal v1.9.0 /go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs =
8888github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M =
8989github.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 =
9092github.com/russross/blackfriday/v2 v2.1.0 /go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM =
9193github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM =
9294github.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 (
2020 "github.com/acorn-io/gptscript/pkg/runner"
2121 "github.com/acorn-io/gptscript/pkg/types"
2222 "github.com/olahol/melody"
23+ "github.com/rs/cors"
2324)
2425
2526type Options struct {
@@ -170,12 +171,14 @@ func (s *Server) Start(ctx context.Context) error {
170171 s .melody .HandleConnect (s .Connect )
171172 go s .events .Start (ctx )
172173 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 }
174176 context .AfterFunc (ctx , func () {
175177 ctx , cancel := context .WithTimeout (context .Background (), 15 * time .Second )
176178 defer cancel ()
177179 _ = server .Shutdown (ctx )
178180 })
181+
179182 return server .ListenAndServe ()
180183}
181184
You can’t perform that action at this time.
0 commit comments