Skip to content

Commit 1c25238

Browse files
VIDSOL-51: Incorrect running instructions for ngrok (#212)
Co-authored-by: Christian Pettet <cpettet11@gmail.com>
1 parent dcb32ef commit 1c25238

File tree

5 files changed

+45
-15
lines changed

5 files changed

+45
-15
lines changed

README.md

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,39 +169,70 @@ The Vonage Video API Reference App for React is currently supported on the lates
169169

170170
## Testing on Multiple Devices
171171

172-
To test the video API across multiple devices on your local network, you can use **ngrok** to expose your frontend publicly.
172+
To test the video API across multiple devices on your local network, you can use **ngrok** to expose your frontend and backend publicly.
173173

174-
1. Create an account at [ngrok](https://dashboard.ngrok.com/signup) if you havent already.
174+
1. Create an account at [ngrok](https://dashboard.ngrok.com/signup) if you haven't already.
175175
176176
2. Follow the [Setup and Installation instructions](https://dashboard.ngrok.com/get-started/setup/) for your operating system to install and configure ngrok.
177177
178-
3. Create a secure tunnel to your frontend using:
178+
3. **Start the application locally first:**
179179
180180
``` bash
181-
yarn forward:frontend
181+
yarn dev
182+
```
183+
184+
Make sure both the backend server (port 3345) and frontend dev server (port 5173) are running before proceeding to the next step.
185+
186+
4. Create secure tunnels for both frontend and backend:
187+
188+
**Set up ngrok configuration:**
189+
190+
First, find your ngrok config file location:
191+
``` bash
192+
ngrok config check
193+
```
194+
195+
Create or edit the ngrok configuration file (typically located at `~/Library/Application Support/ngrok/ngrok.yml` on macOS; `~/.config/ngrok/ngrok.yml` on Linux and `%HOMEPATH%\AppData\Local\ngrok\ngrok.yml` on Windows) with the following content:
196+
197+
``` yaml
198+
version: "2"
199+
tunnels:
200+
frontend:
201+
addr: 5173
202+
proto: http
203+
backend:
204+
addr: 3345
205+
proto: http
206+
```
207+
208+
**Start both tunnels:**
209+
``` bash
210+
ngrok start backend frontend
182211
```
183212
184-
This command creates a publicly accessible HTTPS URL for your frontend. It will appear in your terminal, similar to the image below:
213+
This command will create publicly accessible HTTPS URLs for both your frontend and backend. The output will appear in your terminal, similar to the image below:
185214
186215
<details close>
187216
<summary>ngrok output example</summary>
188-
<img src="./docs/assets/readme/4-forwarding front-end.png" alt="ngrok tunnel example" style="max-width: 100%; height: auto;" />
217+
<img src="./docs/assets/readme/4-forwarding.png" alt="ngrok tunnel example" style="max-width: 100%; height: auto;" />
189218
</details>
190219
191220
</br>
192221
193-
4. Copy the domain from the output and update your **frontend/.env** file:
222+
5. Copy the domains from both outputs and update your **frontend/.env** file:
194223
195224
``` ini
196-
# example
197-
VITE_TUNNEL_DOMAIN=GENERIC_DOMAIN
225+
# Frontend tunnel domain
226+
VITE_TUNNEL_DOMAIN=your-frontend-domain.ngrok.io
227+
# Backend tunnel domain
228+
VITE_API_URL=https://your-backend-domain.ngrok.io
198229
```
199230
200-
**Note:** ngrok assigns a temporary domain. Youll need to update your environment variable each time the domain changes.
231+
**Note:** ngrok assigns temporary domains. You'll need to update your environment variables each time the domains change.
201232

202233
</br>
203234

204-
5. Open the provided **Forwarding** URL in your browser. This exposes your Vite app publicly. However, keep in mind that the backend server is still local, so the devices accessing the app must be on the same local network.
235+
6. Open the provided frontend **Forwarding** URL in your browser. This exposes your entire application publicly, allowing devices on any network to access it.
205236

206237
</br>
207238

-38.6 KB
Binary file not shown.
157 KB
Loading

frontend/src/utils/constants.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import isReportIssueEnabled from './isReportIssueEnabled/isReportIssueEnabled';
33
/**
44
* @constant {string} API_URL - The base URL determined by the current environment.
55
*/
6-
export const API_URL = window.location.origin.includes('localhost')
7-
? 'http://localhost:3345'
8-
: window.location.origin;
6+
export const API_URL =
7+
import.meta.env.VITE_API_URL ||
8+
(window.location.origin.includes('localhost') ? 'http://localhost:3345' : window.location.origin);
99

1010
/**
1111
* @constant {object} DEVICE_ACCESS_STATUS - An object representing various states for device access.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"start:backend": "yarn workspace backend dev",
2828
"debug:backend": "yarn workspace backend debug",
2929
"start:frontend": "yarn workspace frontend dev",
30-
"forward:frontend": "npx ngrok http 5173",
3130
"test": "yarn test:backend && yarn test:frontend",
3231
"test:backend": "yarn workspace backend test",
3332
"test:backend:watch": "yarn workspace backend test:watch",

0 commit comments

Comments
 (0)