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 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: {
        '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, 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


i got the remote url using

git remote get-url origin

and the url is

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
AUG Leaders

Atlassian Community Events