Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ERR_FR_TOO_MANY_REDIRECTS while pushing files to bitbucket using nodejs

Aditya Shrivastava
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 23, 2023
I am trying to push files to bitbucket repo using nodejs. Here is the code I am using
async function pushToRepo(remoteUrl, options, filePath, message) {
  try {
    // Reading file content from file path and encoding to base64 format
    const fileContent = fs.readFileSync(filePath);
    const base64Content = fileContent.toString('base64');

    const formData = new FormData();
    formData.append('message', message);
    formData.append('content', base64Content);
    formData.append('branch', options.branchName);

    const config = {
      headers: {
        ...formData.getHeaders(),
        'User-Agent': 'MyApp/1.0.0', // Optional, but recommended
      },
      auth: {
        username: options.username,
        password: options.password,
      },
      jar: true, // enabling cookie jar support
    };

    const resp = await axios.post(remoteUrl, formData, config);

    // Logging success message with response body
    console.log('Push to repo successful!', resp.body);
  } catch (err) {
    // Logging error message
    console.error('Error pushing to repo:', err);
  }
}

but it is showing

code: 'ERR_FR_TOO_MANY_REDIRECTS'

i got the remote url using

git remote get-url origin

and the url is

https://user_name@bitbucket.org/my-demo/helpcoin.git

password I am using generated from app password from bitbucket

and push is working in that but problem with commit as mentioned in question.

So using the code, in which I don't need to clone the whole repo

what is the issue in this? Am I missing something?

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events