Setting Up For Testing on Mobile
In most cases, to test something on a mobile device, you simply need to open up your developer tools, click "Toggle Device Toolbar", and click one of the phone options from the dropdown to simulate a mobile screen. However, some bugs only happen when testing on a mobile device, such as the ones caused by mobile Safari. This will require testing on the actual tablet or phone to reproduce the issue, so this optional setup guide is to allow you to access your development site on a mobile device, connected to the same network.
For Linux/Mac
You should be able to go directly to the IP of your Linux machine (you can find this through ifconfig
in the console). However, if this does not work, you will need to Google how to open port 80 on the firewall of your Linux distro. Unfortunately, we do not have a more detailed guide on how to do this available because it has been so long since we had a developer on Linux or Mac. If you complete this process for Linux/Mac, you should update the guides for the next developer here.
For Windows
Since most of our developers are set up on Windows, the process is fairly simple for how to make an opening in your firewall to allow a phone to access your apps. It is advisable that you would disable this firewall rule when it is not in use, as the full security ramifications of leaving the firewall rule enabled are not fully known to me.
Setup
-
To begin, navigate to your Apache
vhosts
config, should be located nearC:\xampp\apache\conf\extra\httpd-vhosts.conf
. -
Locate the site that represents your FW apps, typically something like
fw.localhost.com
,fw-[olivetName].localhost.com
, orapps.localhost.com
. -
Ensure that the apps URL is the first entry using the relevant port number. In the example screenshot below,
apps.localhost.com
is valid because it is the first entry.fw.localhost.com
would also be valid because it is the first entry listening on port 8080 -
Open Windows Defender Firewall and click "Advanced Settings".
-
Click "Inbound Rules" then Action > New Rule
-
Select "Port" and click next
-
Select TCP, and "Specific local ports". In the "Specific local ports" field, enter the port number from the Apache config and click next (in the above example, would be 80 for apps.localhost.com or 8080 for fw.localhost.com)
-
Click the "Allow the connection" radio button and click next
-
Check all boxes for "When does this rule apply"
-
Give it any name and description and click finish. I suggest "Apache Test Website".
-
Right click your rule in the "Inbound Rules" list and click properties
-
Click "Program and Services", under Programs click "This program" and click browse
-
Find the httpd executable under
apache
. Should be locatedC:\xampp\apache\bin\httpd.exe
-
Since I am not fully aware of the security side effects of this rule, I suggest disabling it when not in use. You can do this by right clicking it and pressing "Disable Rule". You can enable it at any time by right clicking it and clicking "Enable Rule".
Accessing the site on mobile
Now that it is setup, accessing it is pretty simple:
- Open a command prompt, type
ipconfig
, and locate your IPv4 address. An example address is 172.26.0.1. Note your IP address may change since the previous time you tested the site on mobile.
-
If you do not remember your sites port number, navigate to
C:\xampp\apache\conf\extra\httpd-vhosts.conf
and locate the port in the site config. In the example above, the port for fw.localhost.com is 8080, apps.localhost.com is 80. -
If you normally keep the Firewall rule disabled, locate it in "Windows Defender Firewall" > "Advanced Settings" > "Inbound Rules" and enable it. On the mobile device, navigate to the IP address colon port number. With the examples above, this would be http://172.26.0.1:8080 (fw.localhost.com above). Note that if your port is 80, you can leave off the port number and just navigate to the IP http://172.26.0.1 (apps.localhost.com above)
-
Click on any of the folders to access the related app. The apps will act the same as they do on desktop, so they will use the same user logins and will update properly from
gulp watch
.