INNER CODE UNIT · JavaScript

getIP

Cezerin2/Server · src/ajaxRouter.js:39

const getIP = req => {
	let ip = req.get('x-forwarded-for') || req.ip;

	if (ip && ip.includes(', ')) {
		ip = ip.split(', ')[0];
	}

	if (ip && ip.includes('::ffff:')) {
		ip = ip.replace('::ffff:', '');
	}

	return ip;
};

const getUserAgent = req => req.get('user-agent');

const fillCartItemWithProductData = (products, cartItem) => {
	const product = products.find(p => p.id === cartItem.product_id);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…