which worked fine until I enabled the Basic Auth to avoid the workflow being triggered from other places that my own webpage. So how can I invoke the script passing the credentials to authenticate the chat?
@greg_luis: to avoid the workflow being triggered from other places you can also setup CORS in the chat node and specify your website url like https://www.yourdomain.com
Did you find a solution regarding Basic Auth?
My understanding regarding documentation was to setup bearer token like this:
The Most simplest solution would be (Not secured):
To pass credentials to the Chat Trigger widget, modify your script to include authentication parameters:
<script type="module">
import { createChat } from 'https://cdn.jsdelivr.net/npm/@n8n/chat/dist/chat.bundle.es.js';
createChat({
webhookUrl: 'https://gregluis.app.n8n.cloud/webhook/e985d15f-b2f6-456d-be15-97e0b1544a40/chat',
auth: {
// For basic auth:
username: 'your_username',
password: 'your_password'
// OR for header-based auth:
// httpHeaderName: 'Authorization',
// httpHeaderValue: 'Basic ' + btoa('username:password')
}
});
</script>
Use either the username/password method or the HTTP header method based on your authentication setup.
→ -> → -> → Safest Solution:
The safest approach is to use a server-side proxy to avoid exposing credentials in client-side code:
Create a simple server-side proxy endpoint on your web server:
Unfortunately I still receive a syntax error with the simple solution, also if I do not change anything in my html-file that calls createChat() function.
My calling html runs fine with the chat-node configured with CORS and Authentication None. When I only change the chat-node configuration to basic auth and do not change anything in the html, I receive a 401 (which is ok), but also a syntax error from the chat.bundle.es.js
That seems a little but confusing to me. Maybe it is related to the missing auth, but to rule out an error with the jsdelivr.net js: does this work on your side with your described “simpel solution”?