tendermint / tendermint

⟁ Tendermint Core (BFT Consensus) in Go
https://tendermint.com/
Apache License 2.0
5.71k stars 2.07k forks source link

There is something wrong with CORSAllowedOrigins #2980

Closed abelliumnt closed 5 years ago

abelliumnt commented 5 years ago

config.toml file

# A list of origins a cross-domain request can be executed from
# Default value '[]' disables cors support
# Use '["*"]' to allow any origin
cors_allowed_origins = "[]"

# A list of methods the client is allowed to use with cross-domain requests
cors_allowed_methods = "[HEAD GET POST]"

# A list of non simple headers the client is allowed to use with cross-domain requests
cors_allowed_headers = "[Origin Accept Content-Type X-Requested-With X-Server-Time]"

Load result:

*config = {*github.com/irisnet/irishub/vendor/github.com/tendermint/tendermint/config.Config} 
 BaseConfig = {github.com/irisnet/irishub/vendor/github.com/tendermint/tendermint/config.BaseConfig} 
 *RPC = {*github.com/irisnet/irishub/vendor/github.com/tendermint/tendermint/config.RPCConfig} 
  RootDir = "/home/lhy/temp/debug/iris-normal"
  ListenAddress = "tcp://0.0.0.0:26657"
  CORSAllowedOrigins = {[]string} len:2, cap:2
   0 = "91"
   1 = "93"
  CORSAllowedMethods = {[]string} len:15, cap:24
   0 = "91"
   1 = "72"
   2 = "69"
   3 = "65"
   4 = "68"
   5 = "32"
   6 = "71"
   7 = "69"
   8 = "84"
   9 = "32"
   10 = "80"
   11 = "79"
   12 = "83"
   13 = "84"
   14 = "93"
  CORSAllowedHeaders = {[]string} len:59, cap:80
  GRPCListenAddress = ""
  GRPCMaxOpenConnections = 900
  Unsafe = false
  MaxOpenConnections = 900

It seems that the string array is not well supported by toml serializer. @hleb-albau

Besides, if you repeat to execute tendermint init on the same home, these following sections will be very large.

CORSAllowedOrigins
CORSAllowedMethods
CORSAllowedHeaders
melekes commented 5 years ago

What serializer are you using? [] are not forbidden in strings https://github.com/toml-lang/toml#user-content-string nor do they require escaping.

hleb-albau commented 5 years ago

@HaoyangLiu try without quotes

cors_allowed_origins = []
cors_allowed_methods = [HEAD GET POST]
cors_allowed_headers = [Origin Accept Content-Type X-Requested-With X-Server-Time]
abelliumnt commented 5 years ago
cors_allowed_headers = "[Origin Accept Content-Type X-Requested-With X-Server-Time]"

@hleb-albau The above value is automatically generated by tendermint init

hleb-albau commented 5 years ago
cors_allowed_headers = "[Origin Accept Content-Type X-Requested-With X-Server-Time]"

@hleb-albau The above value is automatically generated by tendermint init

If it without quotes works for you, I will provide pr fixing init.

hleb-albau commented 5 years ago

yeah, already fixed by @melekes . I also fixed docs in https://github.com/tendermint/tendermint/pull/3013

abelliumnt commented 5 years ago

@hleb-albau Well done!

ebuchman commented 5 years ago

Thanks folks!