Basic Auth & Webhook URL for npm installation

Hey there! n8n newbie here :slight_smile:

l have a server environment which (at least for now) only allows me to install n8n via npm. But when doing so, a lot of things are not working. I use a custom domain to access n8n which is installed on a Digitalocean Droplet.

My main problems are the following two:

  1. I can not get basic auth to work. I followed the instructions from the docs (set the N8N_BASIC_AUTH... variables & start n8n) but there’s no auth window appearing. I restarted the server, I restarted n8n, nothing appears. I tested multiple browsers
  2. The redirect URL for API credentials is ...localhost:5678... even after I set the WEBHOOK_URL. echoing it, confirms, it is set. But it just isn’t reflected in the UI.

My question would be: Is the npm installation just limited and I cannot do this stuff? I found a few topics on here that suggest following docs that lead to 404 pages and then redirect to other docs that only show instructions for docker installation. If this is not the case, is there any part of the documentation that I just didn’t find, that could help me with my problems?

Thanks in advance

n8n setup

  • n8n version: 0.159.1
  • Running n8n via: npm 6.14.15 (node 14.18.3)

Hi @wohfab, welcome to the community!

I am sorry to hear you’re having trouble. The npm variant of n8n is able to read environment variables. My first thought after reading your post would be that your environment variables don’t make it through to n8n. Can you confirm how exactly you are setting them and how you launch n8n? And which operating system are you running?

Hi @MutedJam, thanks for the quick reply!

I am running Ubuntu 16.04.7 LTS. I set the variables via:

export N8N_BASIC_AUTH_USER=wohfab
export N8N_BASIC_AUTH_PASSWORD=password

and then started n8n via pm2:

pm2 start n8n

Hi @wohfab, seeing you use pm2, could you give the command from @harshil1712’s blog post on this a go?

So something like N8N_BASIC_AUTH_ACTIVE=true N8N_BASIC_AUTH_USER=<USERNAME> N8N_BASIC_AUTH_PASSWORD=<PASSWORD> pm2 restart n8n --update-env?

Thank you very much, @MutedJam! That works perfectly fine for the basic auth setup :slight_smile: Thank you!

When following @harshil1712’s blog post, could the nginx setup tackle my second problem as well?

If I understand your second problem right, the WEBHOOK_URL environment variable wasn’t taken into account by n8n? You should be able to set in the same way as the other ones (e.g. N8N_BASIC_AUTH_ACTIVE=true N8N_BASIC_AUTH_USER=<USERNAME> N8N_BASIC_AUTH_PASSWORD=<PASSWORD> WEBHOOK_URL= pm2 restart n8n --update-env).

If you haven’t set up a reverse proxy yet, the approach in this blog post would result in a decent setup indeed!

Thank you very much, I followed the blog post a little more and got it working!

1 Like

Awesome, thanks a lot for confirming and happy automating :slight_smile:

1 Like