How to return client IP address in loopback 4

0 votes

I want to return either IPv4/IPv6 IP in the loopback4 application? How do I modify the below code to get IP address?

import {get, param} from '@loopback/rest';

    export class GreetController {       
      @get('/', {
        responses: {
          '200': {
            description: 'greeting text',
            content: {
              'application/json': {
                schema: {type: 'string'},
              },
            },
          },
        },
      })
      greet(@param.query.string('name') name: string) {
        return `hello ${name}`;
      }
    }
Feb 24 in Cyber Security & Ethical Hacking by Edureka
• 5,660 points
62 views

1 answer to this question.

0 votes

You should also add this code in server.js to grant the real ip, otherwise you´re getting the load balancer IP:

app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);

Hope this will help!

For more, enroll in Cyber security masters program today.

Thank you!

answered Mar 2 by Edureka
• 5,960 points

Related Questions In Cyber Security & Ethical Hacking

+1 vote
1 answer

How to find IP address of nodes in my network?

The IP address of the nodes connected ...READ MORE

answered Feb 9, 2019 in Cyber Security & Ethical Hacking by Omkar
• 69,190 points
1,188 views
0 votes
1 answer

How to find MAC address using IP address?

To find the MAC address, run this ...READ MORE

answered Feb 9, 2019 in Cyber Security & Ethical Hacking by Omkar
• 69,190 points
901 views
0 votes
1 answer

How to diagnose a network using loopback address?

C:\Users\priyj_kumar>ping Loopback Pinging DESKTOP-TGAB9Q5 [::1] with 32 bytes ...READ MORE

answered Mar 22, 2019 in Cyber Security & Ethical Hacking by Priyaj
• 58,060 points
777 views
0 votes
1 answer

how to change your ip address?

Try using the following code. This the most ...READ MORE

answered Feb 21 in Cyber Security & Ethical Hacking by Edureka
• 5,660 points
78 views
0 votes
1 answer

How can I force the login to a specific ip address?

Try to access the router's default page. It's ...READ MORE

answered Feb 15 in Cyber Security & Ethical Hacking by Edureka
• 5,660 points
25 views
0 votes
1 answer

How do i check a ip address range whether it falls in Class A,Class B,Class C

class NetworkId{ static String findClass(String str){ int index = ...READ MORE

answered Feb 16 in Cyber Security & Ethical Hacking by Edureka
• 5,960 points
35 views
0 votes
0 answers

How to get Wi-Fi router IP address on iOS?

Is there any way to get Wi-Fi ...READ MORE

Feb 16 in Cyber Security & Ethical Hacking by Edureka
• 5,660 points
27 views
0 votes
0 answers

How to get IP address using nslookup and python on Windows?

One such modification occurred while I was ...READ MORE

Feb 17 in Cyber Security & Ethical Hacking by Edureka
• 5,960 points
52 views
0 votes
1 answer

how to find ip address in cmd

1. Open the Command Prompt.   a. Click the Start icon, ...READ MORE

answered Feb 9 in Cyber Security & Ethical Hacking by Edureka
• 5,960 points
33 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP