n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
45.52k stars 6.27k forks source link

"n8n User Auth" in "Chat Trigger" seems redirect to the wrong url when N8N_PATH is set #9082

Open chhaj5236 opened 5 months ago

chhaj5236 commented 5 months ago

Bug Description

I set N8N_PATH to "/n8n/" and set "Chat Trigger" to "n8n User Auth". Then I open "Chat Url" in a web browser, it will redirect me to http://localhost:5678/signin?redirect=http://localhost:5678/n8n/webhook/xxxx/chat, but http://localhost:5678/signin does not exist.

I checked the source code and found that "Chat Trigger" does not take N8N_PATH as the prefix when trying to check the user auth or redirecting the url.

image

I also checked http://localhost:5678/n8n/rest/login is working as expected, but http://localhost:5678/rest/login is not.

I wonder if I miss something like other environment need to be set?

To Reproduce

  1. Set environment N8N_PATH to /n8n/ and WEBHOOK_URL to http://localhost:5678/n8n/ then deploy the n8n service.
  2. Go to Workflows page and add a new workflow and a Chat Trigger node.
  3. Activate the workflow.
  4. Open Chat Trigger node, Make Chat Plublic Available and set Authentication to n8n User Auth.
  5. Copy Chat Url and open it in the web browser.
  6. The browser will redirect to the url without "/n8n/" and failed.

Expected behavior

should redirect to the Chat Window.

Operating System

n8nio/base

n8n Version

1.31.0

Node.js Version

18.19.1

Database

SQLite (default)

Execution mode

main (default)

Joffcom commented 5 months ago

Hey @chhaj5236,

I have created NODE-1296 as the dev ticket to look into this in more detail, Out of interest is using the n8n_path a requirement in your environment or if needed would you be able to swap to a subdomain instead?

chhaj5236 commented 5 months ago

Hi @Joffcom, thanks for the feedback. It's not easy for us to apply a subdomain, n8n_path is a good feature for us to serve n8n behind a proxy by using a different sub-path.

Joffcom commented 5 months ago

Hey @chhaj5236,

Is that a different sub path for multiple instances? One of the chats we have had internally was around possibly removing support for n8n_path in the future as we don't see it being used that often so it would be great to understand a bit more around what you are doing with it.

chhaj5236 commented 5 months ago

@Joffcom It's not for multiple n8n instances, we have other services behind the proxy.