Skip to content

Commit 7c72189

Browse files
evanmcarlsonEvan Carlson
andauthored
Add more details around testing on mobile (#18)
* Add more details around testing on mobile * Update testing on mobile guides --------- Co-authored-by: Evan Carlson <evan@Evans-MacBook-Pro.local>
1 parent 53d03a8 commit 7c72189

4 files changed

Lines changed: 33 additions & 35 deletions

File tree

docs/engine/overview.md

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -104,41 +104,22 @@ See documentation on the [Camera Pipeline Module API](/docs/api/engine/camerapip
104104

105105
### Test on Mobile
106106

107-
To test your project on mobile devices, especially for AR experiences that require camera access, you'll need to serve your development server over HTTPS.
107+
To test your project on mobile devices, especially for AR experiences that require camera access, you'll need to serve your development server over HTTPS. We recommend using [ngrok](https://ngrok.com/) to create a secure tunnel to your local server.
108108

109-
1. If you do not already have `npm` installed, follow the instructions on this [page](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to set it up.
110-
2. Run `npm install --global http-server` to install the [http-server](https://www.npmjs.com/package/http-server) npm package as a global CLI tool.
111-
3. Install [openssl](https://github.com/openssl/openssl) and generate key.pem and cert.pem files using this command:
112-
```
113-
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
114-
```
115-
116-
You will be prompted with a few questions after entering the command. Use `127.0.0.1` as value for Common name if you want to be able to install the certificate in your OS's root certificate store or browser so that it is trusted.
117-
118-
This generates a cert-key pair and it will be valid for 3650 days (about 10 years).
119-
120-
Then you can run `http-server` with `-S` for enabling SSL and `-C` for your certificate file:
121-
```
122-
npx http-server [project-path] -S -C cert.pem
123-
```
124-
125-
Example:
126-
```
127-
npx http-server gettingstarted/aframe/ -S -C cert.pem
109+
1. Go to [ngrok.com](https://ngrok.com/) and create an account. Once signed in, follow the steps on the dashboard to install ngrok.
110+
2. Update (or verify) your project configuration. In the `config` folder, open `webpack.config.js` and look for the `devServer` object. Add (or verify) ngrok as an `allowedHost`:
111+
```javascript
112+
devServer: {
113+
// ... existing config
114+
allowedHosts: ['.ngrok-free.dev']
115+
}
128116
```
129-
130-
There should be some logs that list a series of local URLs like:
131-
```sh
132-
Available on:
133-
http://127.0.0.1:8080
134-
http://192.168.20.43:8080
135-
http://172.29.29.159:8080
117+
3. `cd` to the project root and run `npm install`. Run `npm run serve` to run the local development server.
118+
4. Open a seperate terminal window and run the following command (in most cases, `[port]` will be `8080`)
119+
```bash
120+
ngrok http [port]
136121
```
137122

138-
:::note
139-
The first IP address listed is `127.0.0.1:8080` (which is the loopback device aka "localhost") and your mobile phone won't be able to connect to that IP address directly. Please use one of the other IP addresses.
140-
:::
141-
142-
Window users need to run the http-server command using a standard Command Prompt window (cmd.exe). The script may generate errors if run from PowerShell.
123+
In the output you should see an ngrok URL that uses HTTPS and forwards to your local development server. You can paste this into your browser window and test your project on a mobile device.
143124

144-
Learn more in the [http-server documentation](https://github.com/http-party/http-server#tlsssl).
125+
![](/images/getting-started/ngrok-terminal.png)

docs/getting-started/testing.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,28 @@ sidebar_position: 6
1616

1717
To test your project on mobile devices, especially for AR experiences that require camera access, you'll need to serve your development server over HTTPS. We recommend using [ngrok](https://ngrok.com/) to create a secure tunnel to your local server.
1818

19-
After setting up ngrok, add the following configuration to `config/webpack.config.js` under the `devServer` section:
20-
19+
1. Go to [ngrok.com](https://ngrok.com/) and create an account. Once signed in, follow the steps on the dashboard to install ngrok.
20+
2. Update (or verify) your project configuration. In the `config` folder, open `webpack.config.js` and look for the `devServer` object. Add (or verify) ngrok as an `allowedHost`:
2121
```javascript
2222
devServer: {
2323
// ... existing config
2424
allowedHosts: ['.ngrok-free.dev']
2525
}
2626
```
27+
3. Relaunch the desktop app or exit/reopen the project to refresh the build after updating the webpack configuration
28+
4. Open the Simulator/Preview and click the browser pop-out button
29+
30+
![DesktopPopout](/images/getting-started/desktop-pop-out.png)
31+
32+
5. From the new browser window, copy the port number appended to the end of the localhost URL
33+
34+
![SimulatorPort](/images/getting-started/simulator-port.png)
35+
36+
4. Open a terminal window and run the following command, replacing [port] with the port obtained from the simulator browser pop-out
37+
```bash
38+
ngrok http [port]
39+
```
40+
41+
In the output you should see an ngrok URL that uses HTTPS and forwards to your local development server. You can paste this into your browser window and test your project on a mobile device.
42+
43+
![](/images/getting-started/ngrok-terminal.png)
1.1 MB
Loading
13.3 KB
Loading

0 commit comments

Comments
 (0)