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

258
Visualizações
Nodejs Koa Framework Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

Greetings to everyone I'm new in NodeJS and I got this error "Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client" and I know on which line of code that error appears but I don't know how to fix it. Can anyone help me here is the code

router.get("(.*)", async (ctx) => {
        try {
          const shop = ctx.query.shop;
          let user = await Shopify_custom_session_storage.findAll({
              raw: true,
              where:{
                shop: shop
              },
              limit:1
            });

          //This shop hasn't been seen yet, go through OAuth to create a sessrsion
          if (user.length == 0 || user[0].shop == undefined) {
            ctx.redirect(`/auth?shop=${shop}`);
          }else{
            await handleRequest(ctx);
            ctx.session.userData = { // Problem appears here
              shop: user[0].shop,
              accessToken: user[0].accessToken
            }; 
          }
          
          // if (ACTIVE_SHOPIFY_SHOPS[shop] == undefined) {
          //   ctx.redirect(`/auth?shop=${shop}`);
          // } else {
          //   await handleRequest(ctx);
          // }
        } catch(err) {
          console.log(err);
          throw err;
        }
      });
about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Did you manage to solve it?

about 4 years ago · Nicolas David Estevez Tovar Relatório

0

about 4 years ago · Nicolas David Estevez Tovar 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