Skip to content

Commit 78084c8

Browse files
committed
added flex local dev
1 parent 7600927 commit 78084c8

File tree

9 files changed

+37
-10
lines changed

9 files changed

+37
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Please visit [Twilio Docs](https://www.twilio.com/docs/flex/developer/plugins) f
3636
* [Plugins API](https://www.twilio.com/docs/flex/developer/plugins/api)
3737
* [Troubleshooting and FAQ](faq.md)
3838

39+
> **Important:** Starting with the latest version, local development uses `flex.local.com` instead of `localhost`. Please see the [FAQ](faq.md) for setup instructions.
40+
3941
## Changelog
4042

4143
Major changelogs can be found in the [changelog directory](/changelog).

faq.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Troubleshooting & FAQ
22

3+
#### Local Development URLs Changed from localhost to flex.local.com
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`.
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
12+
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
18+
19+
After making this change, your local plugin development server will be accessible at `http://flex.local.com:3000` instead of `http://localhost:3000`.
20+
21+
**Quick Setup Script (macOS/Linux only):**
22+
You can also run the provided script to automatically configure your hosts file:
23+
```bash
24+
./scripts/setup-hosts.sh
25+
```
26+
327
#### npm install fails on NPM 7
428

529
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`:

packages/create-flex-plugin/src/lib/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const setupConfiguration = async (config: FlexPluginArguments): Promise<F
4343

4444
config.pluginClassName = `${upperFirst(camelCase(name)).replace('Plugin', '')}Plugin`;
4545
config.pluginNamespace = name.toLowerCase().replace('plugin-', '');
46-
config.runtimeUrl = config.runtimeUrl || 'http://localhost:3000';
46+
config.runtimeUrl = config.runtimeUrl || 'http://flex.local.com:3000';
4747
config.targetDirectory = resolveCwd(name);
4848
config.flexSdkVersion = await packages.getLatestFlexUIVersion(2);
4949
config.pluginScriptsVersion = pkg.devDependencies['@twilio/flex-plugin-scripts'];

packages/flex-dev-utils/src/__tests__/urls.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('urls', () => {
4545

4646
expect(result.local.host).toEqual('0.0.0.0');
4747
expect(result.local.port).toEqual(1234);
48-
expect(result.local.url).toEqual('http://localhost:1234/');
48+
expect(result.local.url).toEqual('http://flex.local.com:1234/');
4949

5050
expect(result.network.host).toEqual('192.0.0.0');
5151
expect(result.network.port).toEqual(1234);
@@ -61,7 +61,7 @@ describe('urls', () => {
6161

6262
expect(result.local.host).toEqual('0.0.0.0');
6363
expect(result.local.port).toEqual(1234);
64-
expect(result.local.url).toEqual('https://localhost:1234/');
64+
expect(result.local.url).toEqual('https://flex.local.com:1234/');
6565

6666
expect(result.network.host).toEqual('192.0.0.0');
6767
expect(result.network.port).toEqual(1234);

packages/flex-dev-utils/src/urls.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ export const findPort = async (startPort: number = 3000): Promise<number> => {
7777
/**
7878
* Returns the local and network urls
7979
* @param port the port the server is running on
80+
* @note Changed from localhost to flex.local.com to avoid login-related issues
8081
*/
8182
export const getLocalAndNetworkUrls = (port: number): InternalServiceUrls => {
8283
const protocol = env.isHTTPS() ? 'https' : 'http';
8384

8485
const localUrl = url.format({
8586
protocol,
8687
port,
87-
hostname: 'localhost',
88+
hostname: 'flex.local.com',
8889
pathname: '/',
8990
});
9091
const networkUrl = url.format({

packages/flex-plugin-e2e-tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ TWILIO_ACCOUNT_SID_drawin=ACxxx TWILIO_AUTH_TOKEN_darwin=123 CONSOLE_EMAIL="user
3434
You can also override certain defaults by setting these additional environment variables:
3535

3636
- `FLEX_UI_VERSION` - the flexUIVersion to use. Defaults to `^1` otherwise
37-
- `PLUGIN_BASE_URL` - the baseUrl. Defaults to `http://localhost:3000` otherwise
37+
- `PLUGIN_BASE_URL` - the baseUrl. Defaults to `http://flex.local.com:3000` otherwise
3838
- `TWILIO_REGION` - the twilio region to use
3939

4040
You can also run a specific step by using (don't forget the environment variables):

packages/flex-plugin-e2e-tests/src/utils/browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class Browser {
1111

1212
private static _page: Page;
1313

14-
private static _domainsToInclude = ['twilio', 'localhost', 'unpkg'];
14+
private static _domainsToInclude = ['twilio', 'localhost', 'flex.local.com', 'unpkg'];
1515

1616
/**
1717
* Initializes browser object

packages/flex-plugin-e2e-tests/src/utils/pages/view/plugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Plugins extends Base {
2828

2929
constructor(page: Page, baseUrl: string) {
3030
super(page);
31-
this._baseUrl = baseUrl.includes('localhost') ? 'https://flex.twilio.com' : baseUrl;
31+
this._baseUrl = baseUrl.includes('flex.local.com') ? 'https://flex.twilio.com' : baseUrl;
3232
}
3333

3434
/**

packages/flex-plugin-e2e-tests/src/utils/pages/view/twilio-console.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ export class TwilioConsole extends Base {
2525
}
2626

2727
/**
28-
* Creates a localhost url
28+
* Creates a flex.local.com url
2929
* @param port
3030
*/
31-
private static _createLocalhostUrl = (port: number) => `http://localhost:${port}&localPort=${port}`;
31+
private static _createLocalhostUrl = (port: number) => `http://flex.local.com:${port}&localPort=${port}`;
3232

3333
/**
3434
* Logs user in through service-login
@@ -39,7 +39,7 @@ export class TwilioConsole extends Base {
3939
*/
4040
async login(flexPath: string, accountSid: string, localhostPort: number, firstLoad: boolean = true): Promise<void> {
4141
logger.info('firstload', firstLoad);
42-
const redirectUrl = this._flexBaseUrl.includes('localhost')
42+
const redirectUrl = this._flexBaseUrl.includes('flex.local.com')
4343
? TwilioConsole._createLocalhostUrl(localhostPort)
4444
: this._flexBaseUrl;
4545
const path = `console/flex/service-login/${accountSid}/?path=/${flexPath}&referer=${redirectUrl}`;

0 commit comments

Comments
 (0)