Тёмный

How to get a user's IP address in an Express App 

Code With Bubb
Подписаться 56 тыс.
Просмотров 8 тыс.
50% 1

In this tutorial, we'll take a quick look at how to get a user' IP address in an Express app.
Here's a snippet of code which you can use to check headers of a Request object in Express to get a user's IP:
const ip =
request.headers['cf-connecting-ip'] ||
request.headers['x-real-ip'] ||
request.headers['x-forwarded-for'] ||
request.socket.remoteAddress || '';
The video goes into a bit more detail but essentially where to get the IP address information from (e.g. which header) depends on the server configuration.
Most likely you'll be running nginx with a proxy so the above code and what we use in the video will work for you.

Опубликовано:

 

11 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 6   
@SumitSingh-wz3wt
@SumitSingh-wz3wt 2 дня назад
What if I use axios or fetch. And modified headers there
@samnako
@samnako Год назад
Can you show us how to do this in php?
@sadiqolekar4911
@sadiqolekar4911 9 месяцев назад
how to get device id of a user?
@fahiyangtech
@fahiyangtech Год назад
Good❤
@doanduchanh8564
@doanduchanh8564 Месяц назад
great
@SASA_maxillo
@SASA_maxillo Год назад
the link: https the program: 😈😈😈
Далее
I Stopped Using Express.js: Because Bun and Hono 🔥
10:23
Apple Event - September 9
1:38:50
Просмотров 25 млн
Client IP in NGINX reverse proxy
8:25
Просмотров 29 тыс.
How to prevent a DDoS attack (or a Brute-force attack)
14:11
How to Host Multiple Node Apps with nginx and pm2
8:20
Get User Location by IP Address - JavaScript Tutorial
15:57
What is an ORM and what does it do?
8:49
Просмотров 1,1 тыс.
3 Coding Secrets I Wish I Knew Earlier
9:38
Просмотров 1 тыс.
The BEST way to do form validation in JavaScript
59:45