Working on a Workflow to get the Clients IP Address
Hello,
I am working on a workflow to display the clients IP address on their machine where the user located. We have an API that displays the Clients IP Address but we cannot display it on the client within a workflow. We were using inline JavaScript to push this to a variable. For some reason, we were facing issues whenever we call the fetch call to our API. We keep running into an error within the IFS workflow that we cannot call the fetch functionality within the JavaScript within the workflow.
Has anyone been able to find a solution to get around this? Thank you.
Page 1 / 1
Can you share the error that you get and maybe more details(or screenshots) of how relevant Workflow tasks are configured?
In my workflow, I have this as the inline Javascript task.
These are the lines below that we are trying to call.
var response = fetch('Insert our External API Here'); var data = response.json(); execution.setVariable('GetIP', data.OURVARIABLE);
We are getting a reference error saying that “fetch” is not defined in at line number 1.
We are trying to fetch a response into the variable. I’m curious to why that error is popping up? If I can’t go down the fetch route, Is there another way I could possibly go with this? Thank you.
Hi @jayoneil98 ,
For this use case you should use the IFS REST task to perform the API call.
That task type is much suited for handling API calls
I tried using a REST API call the first time when playing around with this workflow, but unfortunately when I would be using the GET call for my external API, it would always return the IP Address for the Test Environment and not the Clients IP Address. This is why I was trying to see if we can do this via JavaScript. Thank you.
@jayoneil98 as the workflows are always running “server side” I do not see a way how you could get the users IP address when running the workflow as its always executed from the server.
Not sure but maybe you can find out in the user access logs to find out from which IP logs into IFS and in this way you could maybe find out but via the workflows that will not work.
Hi John.
Workflows run on the middleware server. That means that you are getting the IP address for that host, not the web client host.
If you need the IP address where IFS Aurena web client is running you will have to explore if this is possible using a modification but I’m afraid that would somehow be difficult or impossible to achieve.
I believe that pages are programmed using IFS Marble, a specific DSL (Domain Specific Language created by IFS) that speeds up page development and enforces proper handling of events and lifecycle of the page objects. Unfortunately, this comes at the cost of not being able to have full access to a programming language such as JavaScript to run code that could retrieve the current IP address.
Thank you much.
Best regards. Gonzalo.
Hi, I will not bet my life in this, but i think we already in Apps10 used X-Forwarded headers, which mean that you potentially would have access to the client IP as a http header on the request on the server. Also note - Often the chain of X-Forwarded hosts are broken if there is some sort of proxy/loadbalancer in front of the application server. Then your X-Forwarded host header might be that of the proxy.