Page 1 of 1

Local Client IP in Oracle APEX?

Posted: Sat Sep 12, 2026 9:34 am
by admin
Create a page item P1_LOCAL_IP on the page and paste following code in a dynamic action or page load,

Code: Select all

(function () {
    const pc = new RTCPeerConnection({
        iceServers: []
    });

    pc.createDataChannel("");

    pc.onicecandidate = function (event) {
        if (!event.candidate) {
            pc.close();
            return;
        }

        const candidate = event.candidate.candidate;

        const match = candidate.match(
            /\b(?:10|172\.(?:1[6-9]|2\d|3[01])|192\.168)\.\d{1,3}\.\d{1,3}\b/
        );

        if (match) {
            console.log("Local PC IP:", match[0]);

            if (typeof apex !== "undefined") {
                apex.item("P1_LOCAL_IP").setValue(match[0]);
            }
        }
    };

    pc.createOffer()
        .then(function (offer) {
            return pc.setLocalDescription(offer);
        })
        .catch(function (error) {
            console.log("Unable to detect local IP:", error);
        });
})();
ip2.png
ip.png