Skip to content

Instantly share code, notes, and snippets.

@vaskaloidis
Last active January 7, 2021 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaskaloidis/590b837a1f0cc9adf0bc20049a0ac1b5 to your computer and use it in GitHub Desktop.
Save vaskaloidis/590b837a1f0cc9adf0bc20049a0ac1b5 to your computer and use it in GitHub Desktop.
ngrok
if Rails.const_defined? 'Server'
options = { addr: ENV.fetch('PORT') { 3000 } }
puts 'Starting Ngrok'
Ngrok::Tunnel.start(options)
puts '[NGROK] tunneling at ' + Ngrok::Tunnel.ngrok_url_https
config.hosts << Ngrok::Tunnel.ngrok_url_https
ENV['api_return_url_base'] = Ngrok::Tunnel.ngrok_url_https
puts "[Ngrok] ENV VARIABLE api_return_url_base: #{ENV["api_return_url_base"]}"
end
at_exit do
if Rails.const_defined? 'Server'
if Ngrok::Tunnel.running?
puts 'Stopping Ngrok'
Ngrok::Tunnel.stop
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment