|
1 | 1 | # Troubleshooting & FAQ |
2 | 2 |
|
3 | | -#### Local Development URLs Changed from localhost to flex.local.com |
| 3 | +#### Configuring Custom Domain for Local Development |
4 | 4 |
|
5 | | -Starting with this version, local plugin development uses `flex.local.com` instead of `localhost` to avoid login-related issues. You need to configure your local hosts file to point `flex.local.com` to `127.0.0.1`. |
| 5 | +You can configure a custom domain for local plugin development using the `--domain` flag. This is particularly important when using SSO v2 (OAuth flow), as `localhost` can cause authentication issues during login due to OAuth redirect URI restrictions. |
6 | 6 |
|
7 | | -**On macOS/Linux:** |
8 | | -1. Open Terminal |
9 | | -2. Run: `sudo vim /etc/hosts` (or use your preferred text editor) |
10 | | -3. Add this line: `127.0.0.1 flex.local.com` |
11 | | -4. Save the file |
| 7 | +**Why use a custom domain?** |
| 8 | +- **SSO v2 OAuth Flow**: If you're using Twilio Flex with SSO v2 (OAuth authentication flow), `localhost` URLs may not be accepted as valid redirect URIs, causing login authentication failures |
| 9 | +- **CORS Issues**: Some authentication systems restrict `localhost` for security reasons |
| 10 | +- **Development Consistency**: Using a custom domain provides a more production-like development environment |
12 | 11 |
|
13 | | -**On Windows:** |
14 | | -1. Open Notepad as Administrator |
15 | | -2. Open the file: `C:\Windows\System32\drivers\etc\hosts` |
16 | | -3. Add this line: `127.0.0.1 flex.local.com` |
17 | | -4. Save the file |
| 12 | +**Usage:** |
| 13 | +```bash |
| 14 | +twilio flex:plugins:start --domain flex.local.com |
| 15 | +``` |
| 16 | + |
| 17 | +**Setting up the custom domain:** |
| 18 | +1. **macOS/Linux**: Add the domain to `/etc/hosts` |
| 19 | + ```bash |
| 20 | + sudo echo "127.0.0.1 flex.local.com" >> /etc/hosts |
| 21 | + ``` |
| 22 | + |
| 23 | +2. **Windows**: Add the domain to `C:\Windows\System32\drivers\etc\hosts` |
| 24 | + ``` |
| 25 | + 127.0.0.1 flex.local.com |
| 26 | + ``` |
| 27 | + |
| 28 | +**Available Options:** |
| 29 | +- Without `--domain`: Uses `localhost` (default behavior, may cause issues with SSO v2) |
| 30 | +- With `--domain flex.local.com`: Uses `flex.local.com` |
| 31 | +- With `--domain my-custom.dev`: Uses any custom domain you prefer |
18 | 32 |
|
19 | | -After making this change, your local plugin development server will be accessible at `http://flex.local.com:3000` instead of `http://localhost:3000`. |
| 33 | +**When is this required?** |
| 34 | +- **SSO v2 Users**: If your Twilio Flex instance uses SSO v2 with OAuth authentication, you will likely encounter login failures when using `localhost` |
| 35 | +- **CORS-restricted environments**: Some authentication providers block `localhost` requests |
| 36 | +- **Custom OAuth configurations**: If your OAuth provider has strict redirect URI policies |
20 | 37 |
|
21 | | -**Quick Setup Script (macOS/Linux only):** |
22 | | -You can also run the provided script to automatically configure your hosts file: |
| 38 | +After configuring your hosts file, your local plugin development server will be accessible at the specified domain (e.g., `http://flex.local.com:3000`). |
| 39 | + |
| 40 | +#### SSO v2 OAuth Authentication Issues with localhost |
| 41 | + |
| 42 | +If you're experiencing login failures during local development, especially with error messages related to OAuth redirects or authentication, this is likely due to SSO v2 OAuth flow restrictions with `localhost` URLs. |
| 43 | + |
| 44 | +**Common Error Symptoms:** |
| 45 | +- Login redirects fail or loop infinitely |
| 46 | +- OAuth callback errors mentioning invalid redirect URI |
| 47 | +- Authentication timeouts during local development |
| 48 | +- CORS errors related to authentication endpoints |
| 49 | + |
| 50 | +**Solution:** |
| 51 | +Use the `--domain` flag with a custom domain: |
23 | 52 | ```bash |
24 | | -./scripts/setup-hosts.sh |
| 53 | +twilio flex:plugins:start --domain flex.local.com |
25 | 54 | ``` |
26 | 55 |
|
| 56 | +Make sure to add the domain to your hosts file as described above. This resolves the OAuth redirect URI validation issues that occur with `localhost`. |
| 57 | + |
27 | 58 | #### npm install fails on NPM 7 |
28 | 59 |
|
29 | 60 | If you are using `npm 7` (you can find out the version by typing `npm -v` in your terminal), then you may get the following error when you run `npm install`: |
|
0 commit comments