diff --git a/go.mod b/go.mod index b73b587..0006d16 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/multiformats/go-multicodec v0.9.0 // indirect github.com/multiformats/go-multihash v0.0.15 // indirect github.com/multiformats/go-varint v0.0.6 // indirect + github.com/rs/cors v1.10.1 // indirect golang.org/x/crypto v0.1.0 // indirect golang.org/x/sys v0.1.0 // indirect ) diff --git a/go.sum b/go.sum index 8a60b18..d6f0672 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,8 @@ github.com/multiformats/go-multihash v0.0.15 h1:hWOPdrNqDjwHDx82vsYGSDZNyktOJJ2d github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg= github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= +github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= diff --git a/main.go b/main.go index e68536b..587c8cc 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ import ( "github.com/julienschmidt/httprouter" mc "github.com/multiformats/go-multicodec" mh "github.com/multiformats/go-multihash" + "github.com/rs/cors" ) const AUTH_TOKEN = "development-token" @@ -189,5 +190,6 @@ func main() { fmt.Printf("listening: %s\n", binding) fmt.Printf("public path: %s\n", publicPath) - log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), router)) + handler := cors.Default().Handler(router) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), handler)) }