Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Last active October 12, 2021 08:21
Show Gist options
  • Save ahmadawais/a0509dd179ec511152c5 to your computer and use it in GitHub Desktop.
Save ahmadawais/a0509dd179ec511152c5 to your computer and use it in GitHub Desktop.
Gulp: Useing ngrok with BrowserSync
// first run npm install ngrok - then put var ngrok = require('ngrok'); at the top of your gulpfile
var ngrok = require('ngrok');
var browserSync = require('browser-sync')
browserSync({
server: "./app"
}, function (err, bs) {
ngrok.connect(bs.options.get('port'), function (err, url) {
// https://757c1652.ngrok.com -> 127.0.0.1:8080
});
});
@abdihaikal
Copy link

What is meen "bs"?

bs in function (err, bs) means the BrowserSync instance created.

@lajennylove
Copy link

lajennylove commented Oct 12, 2021

Hi, I tried to use you script to proxy a local project with Ngrok but nothing happens...

This is what I added to my gulpfile.js
var ngrok = require('ngrok'); var browserSync = require('browser-sync') browserSync({ proxy: '10.0.0.87:8888/test-site/', port: 8888, open: false, notify: false }, function (err, browserSync) { ngrok.connect(browserSync.options.get('port'), function (err, url) { // https://757c1652.ngrok.com -> 127.0.0.1:8080 }); });

This is my MAMP's internal network url: 10.0.0.87:8888/testsite/

But this is what my Gulp says:

`

   Local: http://localhost:8890/test-site/

External: http://10.0.0.87:8890/test-site/

      UI: http://localhost:3001

UIExternal: http://localhost:3001


`

Internally works perfect between my devices, but when I try to see it outside my home lan I just can't. What can I do?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment