diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6ed2849f..e2b4c5e18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ concurrency: env: NODE_VERSION: '24' - GO_VERSION: '1.24' + GO_VERSION: '1.25.x' jobs: # Detect which components have changed diff --git a/synkronus-cli/internal/auth/auth.go b/synkronus-cli/internal/auth/auth.go index 99487436a..0bef107f1 100644 --- a/synkronus-cli/internal/auth/auth.go +++ b/synkronus-cli/internal/auth/auth.go @@ -41,8 +41,21 @@ func Login(username, password string) (*TokenResponse, error) { return nil, fmt.Errorf("error marshaling login data: %w", err) } + // Create request with headers + req, err := http.NewRequest("POST", loginURL, bytes.NewBuffer(jsonData)) + if err != nil { + return nil, fmt.Errorf("error creating login request: %w", err) + } + req.Header.Set("Content-Type", "application/json") + // Add x-formulus-version header (required by some servers) + apiVersion := viper.GetString("api.version") + if apiVersion != "" { + req.Header.Set("x-formulus-version", apiVersion) + } + // Send login request - resp, err := http.Post(loginURL, "application/json", bytes.NewBuffer(jsonData)) + client := &http.Client{} + resp, err := client.Do(req) if err != nil { return nil, fmt.Errorf("login request failed for endpoint %s: %w", loginURL, err) } @@ -60,9 +73,6 @@ func Login(username, password string) (*TokenResponse, error) { return nil, fmt.Errorf("error reading response body: %w", err) } - // Print the raw response for debugging - fmt.Printf("DEBUG - Raw API response: %s\n", string(body)) - // Parse response var tokenResp TokenResponse if err := json.Unmarshal(body, &tokenResp); err != nil { @@ -93,8 +103,21 @@ func RefreshToken() (*TokenResponse, error) { return nil, fmt.Errorf("error marshaling refresh data: %w", err) } + // Create request with headers + req, err := http.NewRequest("POST", refreshURL, bytes.NewBuffer(jsonData)) + if err != nil { + return nil, fmt.Errorf("error creating refresh request: %w", err) + } + req.Header.Set("Content-Type", "application/json") + // Add x-formulus-version header (required by some servers) + apiVersion := viper.GetString("api.version") + if apiVersion != "" { + req.Header.Set("x-formulus-version", apiVersion) + } + // Send refresh request - resp, err := http.Post(refreshURL, "application/json", bytes.NewBuffer(jsonData)) + client := &http.Client{} + resp, err := client.Do(req) if err != nil { return nil, fmt.Errorf("refresh request failed: %w", err) } diff --git a/synkronus-cli/pkg/client/client.go b/synkronus-cli/pkg/client/client.go index 8862ce3cd..b72b0a2ba 100644 --- a/synkronus-cli/pkg/client/client.go +++ b/synkronus-cli/pkg/client/client.go @@ -107,8 +107,8 @@ func (c *Client) GetVersion() (*SystemVersionInfo, error) { } func (c *Client) doRequest(req *http.Request) (*http.Response, error) { - // Add API version header - req.Header.Set("x-api-version", c.APIVersion) + // Add API version header (x-formulus-version is required by some servers) + req.Header.Set("x-formulus-version", c.APIVersion) // Get authentication token token, err := auth.GetToken() @@ -447,9 +447,9 @@ func (c *Client) SyncPull(clientID string, currentVersion int64, schemaTypes []s req.Header.Set("Content-Type", "application/json") - // Add API version header + // Add API version header (x-formulus-version is required by some servers) if c.APIVersion != "" { - req.Header.Set("x-api-version", c.APIVersion) + req.Header.Set("x-formulus-version", c.APIVersion) } // Send request