Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
puppeteer page navigation issues with heroku deployment

I am using TD Ameritrade's API and am trying to implement an automated work flow for the access token refresh process. I have chosen to use the npm package "puppeteer" to programmatically login to the TD Ameritrade developer website and retrieve my code(a long string that needs to be URL decoded needed for the access token refresh process) from a URI that the bot gets redirected to after logging in and accepting the terms for further permissions to access my trading account.

Everything worked fine on my end, but when I deployed my code to heroku the redirect to the URI does not happen and I am only able to grab the URL of the site I was on before the redirect to the URI.

Here is my code:

const getTdAmeritradeCode = async () => {
    const browser = await puppeteer.launch({
        headless: true,
        args: ['--no-sandbox','--disable-setuid-sandbox']
    });

    const page = await browser.newPage();
    await page.goto(process.env.REFRESH_TOKEN_REFRESH_LINK);
    await page.type("#username0", process.env.TD_AMERITRADE_USERNAME);
    await page.type("#password1", process.env.TD_AMERITRADE_PASSWORD);
    const [response0] = await Promise.all([
        page.waitForNavigation(),
        page.click("#accept"),
    ]);
    const [response1] = await Promise.all([
        page.waitForNavigation(),
        page.click("#accept"),
    ]);

    let tdAmeritradeCode = decode(await page.url().slice(50)); // 50 is the number of characters in the url before the code
    await browser.close();
    return tdAmeritradeCode;
}

That is the method I have found on the puppeteer documentation, but it does not seem to be working. Like I said earlier, the code works as intended on my machine but when deployed on heroku the code fails the response1 Promise and does not get redirected to the URI.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The issue was I had my TD Ameritrade application redirect to my Heroku application's URL. I believe it's due to the fact that Heroku applications are not meant to make a GET request to themselves. I ended up changing the redirect URI in my TD Ameritrade and Heroku applications and I was able to get the code without problem.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda