puma-ngrok-tunnel

Have a ngrok tunnel open when you start Puma in Development
Icons/chart bar
Used 37 times
Created by
M Mike Rogers

Usage
This installs the puma-ngrok-tunnel gem, which will automatically start a ngrok tunnel to your localhost. It's super handy for showing other people your rails app, or listening to webhooks.

Install ngrok locally:

brew tap caskroom/cask
brew cask install ngrok

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/xkjseg"
Template Source

Review the code before running this template on your machine.

gem_group :development do
  gem 'puma-ngrok-tunnel'
end

run 'bundle'

inject_into_file 'config/puma.rb' do
  <<~EOF
    plugin :ngrok_tunnel if ENV.fetch('RAILS_ENV') { 'development' } == 'development'
  EOF
end


environment nil, env: 'development' do
   <<~EOF
   # puma-ngrok-tunnel: Allow connections from ngrok
   config.hosts << /[a-z0-9.-]+\.ngrok\.io/
   
   EOF
end
Comments

Sign up or Login to leave a comment.