You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After to generate the QRcode or even already authenticated i can't make a redirect after client.initialize(), because i receive this message error:
node:_http_outgoing:696
throw new ERR_HTTP_HEADERS_SENT('set');
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
Expected behavior
after to authenticated, be redirected to other page
Steps to Reproduce the Bug or Issue
//Async basic function requested by front-end:
gerar_qrcode: async function (req, res) {
const QRcode = require('qrcode');
client.on('qr', (qr) => {
const url = qr;
QRcode.toDataURL(url, (err, qrCodeUrl) => {
if (err) {
return console.log('erro ' + err);
}
return res.view({ qr_gerado: qrCodeUrl });
})
//if Authenticated redirect my front-end to the page called home:
}).on('authenticated', () => {
console.log('User Authenticated!');
return res.redirect('/pages/home');
});
client.initialize();
},
Relevant Code
//Full error message:
User Authenticated!
node:_http_outgoing:696
throw new ERR_HTTP_HEADERS_SENT('set');
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (node:_http_outgoing:696:11)
at ServerResponse.header (/Users/ademir/apps/logchat/node_modules/express/lib/response.js:776:10)
at ServerResponse.location (/Users/ademir/apps/logchat/node_modules/express/lib/response.js:893:15)
at ServerResponse.redirect (/Users/ademir/apps/logchat/node_modules/express/lib/response.js:931:18)
at Client. (/Users/ademir/apps/logchat/api/controllers/PagesController.js:294:18)
at Client.emit (node:events:515:28)
at Client.initialize (/Users/ademir/apps/logchat/node_modules/whatsapp-web.js/src/Client.js:707:14)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
Node.js v21.0.0
[nodemon] app crashed - waiting for file changes before starting...
Browser Type
Chromium
WhatsApp Account Type
WhatsApp Business
Does your WhatsApp account have multidevice enabled?
No, I am not using Multi Device
Environment
OS: Mac
"node": "^21.0.0",
"whatsapp-web.js": "^1.23.0",
Additional context
there is some other way to check if client is authenticated?
thank you guys! i just posted it here because the Official WWebJS Discord Server is not working.
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Describe the bug
After to generate the QRcode or even already authenticated i can't make a redirect after client.initialize(), because i receive this message error:
node:_http_outgoing:696
throw new ERR_HTTP_HEADERS_SENT('set');
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
Expected behavior
after to authenticated, be redirected to other page
Steps to Reproduce the Bug or Issue
//Async basic function requested by front-end:
gerar_qrcode: async function (req, res) {
const QRcode = require('qrcode');
client.on('qr', (qr) => {
const url = qr;
QRcode.toDataURL(url, (err, qrCodeUrl) => {
if (err) {
return console.log('erro ' + err);
}
return res.view({ qr_gerado: qrCodeUrl });
})
//if Authenticated redirect my front-end to the page called home:
}).on('authenticated', () => {
console.log('User Authenticated!');
return res.redirect('/pages/home');
});
client.initialize();
},
Relevant Code
//Full error message:
User Authenticated!
node:_http_outgoing:696
throw new ERR_HTTP_HEADERS_SENT('set');
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (node:_http_outgoing:696:11)
at ServerResponse.header (/Users/ademir/apps/logchat/node_modules/express/lib/response.js:776:10)
at ServerResponse.location (/Users/ademir/apps/logchat/node_modules/express/lib/response.js:893:15)
at ServerResponse.redirect (/Users/ademir/apps/logchat/node_modules/express/lib/response.js:931:18)
at Client. (/Users/ademir/apps/logchat/api/controllers/PagesController.js:294:18)
at Client.emit (node:events:515:28)
at Client.initialize (/Users/ademir/apps/logchat/node_modules/whatsapp-web.js/src/Client.js:707:14)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
Node.js v21.0.0
[nodemon] app crashed - waiting for file changes before starting...
Browser Type
Chromium
WhatsApp Account Type
WhatsApp Business
Does your WhatsApp account have multidevice enabled?
No, I am not using Multi Device
Environment
OS: Mac
"node": "^21.0.0",
"whatsapp-web.js": "^1.23.0",
Additional context
there is some other way to check if client is authenticated?
thank you guys! i just posted it here because the Official WWebJS Discord Server is not working.
The text was updated successfully, but these errors were encountered: