Skip to content

Commit

Permalink
Fix eu api key
Browse files Browse the repository at this point in the history
  • Loading branch information
slavovojacek committed Feb 8, 2025
1 parent 3e0c076 commit d27ce4f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ func CreateOts(ctx context.Context, encryptedBytes []byte, expiresIn time.Durati
return nil, fmt.Errorf("no API URL configured for region: %s", region)
}

apiKey := viper.GetString("apiKey")
apiKey := viper.GetString(fmt.Sprintf("apiKey.%s", region))
if apiKey == "" {
return nil, fmt.Errorf("no API key configured for region: %s", region)
}

// Build the request
reqURL, err := url.Parse(apiURL)
Expand All @@ -86,11 +89,7 @@ func CreateOts(ctx context.Context, encryptedBytes []byte, expiresIn time.Durati
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Client-Name", "ots-cli")
req.Header.Set("X-Client-Version", build.Version)

// Add optional authentication (for self-hosted)
if apiKey != "" {
req.Header.Set("X-Api-Key", apiKey)
}
req.Header.Set("X-Api-Key", apiKey)

client := &http.Client{
Timeout: 30 * time.Second,
Expand Down

0 comments on commit d27ce4f

Please sign in to comment.