Ionic PWA: How to transfer server ip from php into the ionic app?

Hi there,

I like Ionic PWA: No need for app installation, just calling a page on a webserver and the app is running on the smartphone in the browser.

My app needs for some reason the ip address of the webserver it is running on. So, the solution needs to work on server side while acting the php interpreter before it got send out to the smartphone browser.

On Php I get the string of the ip address with

getHostByName(getHostName()); // returns something like ‘’

How to transfer this result string from php into the Ionic PWA app?

Do I have to rename the index.html into a index.php and play around with value-attributes that get the string injected/binded like

<input hidden [ngModel]=“whatever” value="<?= getHostByName(getHostName()); ?>">

Okay then …

I renamed the index.html to index.php, changed the references from index.html to index.php in angular.json, config.xml and nsgw-config.json too.

So after a build there is a index.php in the www folder instead of the index.html and it runs the php interpreter when called from the server.

In the index.php there I set a constant. Here the whole index.php

<!DOCTYPE html>

  <!-- Here is the constant I use later in the Ionic Pwa App -->
  <script type="text/javascript">
    const URL = 'whatever://<?= getHostByName(getHostName()); ?>:1234/';