Skip to content

Commit

Permalink
change to allowed-origins
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Apr 27, 2023
1 parent 11fbf72 commit 78e3de1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,12 @@ A valid email address is necessary for the creation of the certificate, and is i

When accessing DefraDB through a frontend interface, you may be confronted with a CORS error. That is because, by default, DefraDB will not have any allowed origins set. To specify which origins should be allowed to access your DefraDB endpoint, you can specify them when starting the database:
```shell
defradb start --allowedorigins=https://yourdomain.com
defradb start --allowe-dorigins=https://yourdomain.com
```

If running a frontend app locally on localhost, allowed origins must be set with the port of the app:
```shell
defradb start --allowedorigins=http://localhost:3000
defradb start --allowed-origins=http://localhost:3000
```

The catch-all `*` is also a valid origin.
Expand Down
6 changes: 3 additions & 3 deletions cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ func MakeStartCommand(cfg *config.Config) *cobra.Command {
}

cmd.Flags().StringArray(
"allowedorigins", cfg.API.AllowedOrigins,
"allowed-origins", cfg.API.AllowedOrigins,
"List of origins to allow for CORS requests",
)
err = cfg.BindFlag("api.allowedorigins", cmd.Flags().Lookup("allowedorigins"))
err = cfg.BindFlag("api.allowed-origins", cmd.Flags().Lookup("allowed-origins"))
if err != nil {
log.FeedbackFatalE(context.Background(), "Could not bind api.allowedorigins", err)
log.FeedbackFatalE(context.Background(), "Could not bind api.allowed-origins", err)
}

cmd.Flags().String(
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (dbcfg DatastoreConfig) validate() error {
type APIConfig struct {
Address string
TLS bool
AllowedOrigins []string
AllowedOrigins []string `mapstructure:"allowed-origins"`
PubKeyPath string
PrivKeyPath string
Email string
Expand Down
2 changes: 1 addition & 1 deletion config/configfile_yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ api:
# Whether the API server should listen over HTTPS
tls: {{ .API.TLS }}
# The list of origins a cross-domain request can be executed from.
# allowedorigins: {{ .API.AllowedOrigins }}
# allowed-origins: {{ .API.AllowedOrigins }}
# The path to the public key file. Ignored if domains is set.
pubkeypath: {{ .API.PubKeyPath }}
# The path to the private key file. Ignored if domains is set.
Expand Down

0 comments on commit 78e3de1

Please sign in to comment.