Skip to content

Commit

Permalink
Fix: Allow CORS visit to Committee Indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyueli8227 committed Apr 12, 2024
1 parent 45f1599 commit abe9af4
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 49 deletions.
10 changes: 10 additions & 0 deletions apis/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"encoding/base64"
"fmt"
"net/http"
"time"

"github.com/RiemaLabs/modular-indexer-committee/ord"
"github.com/RiemaLabs/modular-indexer-committee/ord/stateless"
verkle "github.com/ethereum/go-verkle"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)

Expand Down Expand Up @@ -240,6 +242,14 @@ func StartService(queue *stateless.Queue, enableCommittee bool, enableDebug bool
}
r := gin.Default()

r.Use(gin.Recovery(), gin.Logger(), cors.New(cors.Config{
AllowOrigins: []string{"*"},
AllowMethods: []string{"POST", "GET"},
AllowHeaders: []string{"Origin", "Content-Type", "Content-Length"},
AllowCredentials: true,
MaxAge: 12 * time.Hour,
}))

// TODO: Medium. Add the TRUSTED_PROXIES to our config
// trustedProxies := os.Getenv("TRUSTED_PROXIES")
// if trustedProxies != "" {
Expand Down
26 changes: 14 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ require (
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.11
github.com/aws/aws-sdk-go-v2/service/s3 v1.52.1
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233
github.com/ethereum/go-verkle v0.1.1-0.20240119133216-f8289fc59149
github.com/gin-contrib/cors v1.7.1
github.com/gin-gonic/gin v1.9.1
github.com/holiman/uint256 v1.2.4
github.com/spf13/cobra v1.8.0
Expand Down Expand Up @@ -55,17 +57,17 @@ require (
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/btcsuite/winsvc v1.0.0 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/bytedance/sonic v1.11.3 // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/cockroachdb/datadriven v1.0.0 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
Expand All @@ -79,7 +81,7 @@ require (
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/go-playground/validator/v10 v10.19.0 // indirect
github.com/gobuffalo/envy v1.7.0 // indirect
github.com/gobuffalo/packd v0.3.0 // indirect
github.com/gobuffalo/packr v1.30.1 // indirect
Expand Down Expand Up @@ -120,9 +122,9 @@ require (
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kkdai/bstream v1.0.0 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lib/pq v1.10.3 // indirect
github.com/libsv/go-bk v0.1.6 // indirect
github.com/libsv/go-bt/v2 v2.2.2 // indirect
Expand All @@ -139,15 +141,15 @@ require (
github.com/lightningnetwork/lnd/tlv v1.1.0 // indirect
github.com/lightningnetwork/lnd/tor v1.1.0 // indirect
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mholt/archiver/v3 v3.5.0 // indirect
github.com/miekg/dns v1.1.43 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nwaples/rardecode v1.1.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/pierrec/lz4/v4 v4.1.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -161,12 +163,12 @@ require (
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
Expand All @@ -188,7 +190,7 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/arch v0.7.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.22.0 // indirect
Expand Down
Loading

0 comments on commit abe9af4

Please sign in to comment.