Skip to content

Commit 9a359b6

Browse files
committed
bump 0.0.5
1 parent 7637212 commit 9a359b6

7 files changed

Lines changed: 41 additions & 16 deletions

File tree

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ module.exports = {
3131
// autoRewrite: true, //default value
3232
// host: 'http://localhost:3000' //default value
3333
},
34+
externalRedirects: [
35+
{
36+
match: '/api/auth/callback',
37+
replace: ['https://prod.domain.com', 'http://localhost:3001'],
38+
},
39+
],
3440
// allowHeaders: 'content-type', //default cors value
3541
},
3642
staging: {
@@ -44,26 +50,36 @@ module.exports = {
4450
```
4551

4652
## 💥 Run
47-
```
53+
```shell
4854
your-dev-server start
4955
npx localhostify prod
5056
npx localhostify staging
5157
```
58+
Browse `http://localhost:3001` and `http://localhost:3002` to enjoy local frotend mixed with real backends enviroments! Hot reload works concurrently!!
59+
5260

53-
Browse `http://localhost:3001` and `http://localhost:3002` to enjoy local frotend mixed with real backends enviroments!<br/>
54-
Hot reload works concurrently!!
61+
## 🍭 External Redirects
62+
If your application use external login or SSO you will need to forward browser redirect to localhost.
63+
This happens on the browser side, so we need a web extension.
64+
65+
```shell
66+
npx localhostify --chrome-ext
67+
```
68+
This command will create a folder ".localhostify-ext" on your project. Load it on Chrome. That's all!.
69+
Note: if you update your .localhostify.js config, please execute again `npx localhostify --chrome-ext` to update also the ext.
70+
It the browser is opened, refresh all the exstensions.
5571

56-
<br/><br/>
5772

58-
## 👏 Contributing
73+
### 👏 Contributing
5974

6075
If you are interested in contributing to `localhostify`, open an issue or a pr!
6176

62-
## 🎉 Thanks
77+
### 🎉 Credits
6378

64-
Thank You, Open Source!
79+
Thank You, Open Source! </br>
80+
Chrome Ext inspired by requestly.io
6581

66-
## 📜 License
82+
### 📜 License
6783

6884
`localhostify` is 100% free and open-source, under [MIT](LICENSE).
6985

bin/createConfig.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const config = require(process.cwd() + '/.localhostify.js');
44
const externalRedirects = Object.values(config).reduce((all, v) => [...all, ...v.externalRedirects], []);
55
const chromeConfig = '__LOCALHOSTIFY__ = ' + JSON.stringify({ externalRedirects }, 0, 3);
66

7-
const extDir = process.cwd() + '/localhostify-ext';
7+
const extDir = process.cwd() + '/.localhostify-ext';
88

99
if (!fs.existsSync(extDir)) {
1010
fs.mkdirSync(extDir);
@@ -14,8 +14,8 @@ if (!fs.existsSync(extDir + '/scripts')) {
1414
}
1515

1616
fs.writeFileSync(process.cwd() + '/localhostify-ext/config.js', chromeConfig);
17-
fs.copyFileSync(__dirname + '/../chrome-ext/manifest.json', process.cwd() + '/localhostify-ext/manifest.json');
18-
fs.copyFileSync(__dirname + '/../chrome-ext/scripts/http.js', process.cwd() + '/localhostify-ext/scripts/http.js');
19-
fs.copyFileSync(__dirname + '/../chrome-ext/scripts/fetch.js', process.cwd() + '/localhostify-ext/scripts/fetch.js');
17+
fs.copyFileSync(__dirname + '/../chrome-ext/manifest.json', process.cwd() + '/.localhostify-ext/manifest.json');
18+
fs.copyFileSync(__dirname + '/../chrome-ext/scripts/http.js', process.cwd() + '/.localhostify-ext/scripts/http.js');
19+
fs.copyFileSync(__dirname + '/../chrome-ext/scripts/fetch.js', process.cwd() + '/.localhostify-ext/scripts/fetch.js');
2020

2121
console.log("Localhostify: Chrome Ext created in localhostify-ext folder.");

chrome-ext/icon_128.png

4.11 KB
Loading

chrome-ext/manifest.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
22
"name": "Localhostify",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"manifest_version": 2,
55
"description": "Localhostify: External redirects interceptor",
6+
"author": "Salvatore Ravidà",
7+
"homepage_url": "https://github.com/salvoravida/localhostify",
8+
"icons": {
9+
"128": "icon_128.png"
10+
},
611
"background": {
712
"scripts": ["config.js", "scripts/http.js"]
813
},

chrome-ext/scripts/fetch.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/* handle custom redirects after fetch */
1+
/**
2+
* https://github.com/salvoravida/localhostify
3+
*/
24

35
function interceptor() {
46
const externalMatches = ['accounts.google.com'];

chrome-ext/scripts/http.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/* HTTP headers Location redirect */
1+
/**
2+
* https://github.com/salvoravida/localhostify
3+
*/
24

35
const { externalRedirects } = window.__LOCALHOSTIFY__;
46

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "localhostify",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Easy HTTP reverse proxy - localhost:3001 -> prod.domain.com",
55
"source": "src/index.js",
66
"main": "./dist/index.js",

0 commit comments

Comments
 (0)