Skip to content

Instantly share code, notes, and snippets.

@vaskaloidis
Last active January 7, 2021 19:00
Show Gist options
  • Select an option

  • Save vaskaloidis/590b837a1f0cc9adf0bc20049a0ac1b5 to your computer and use it in GitHub Desktop.

Select an option

Save vaskaloidis/590b837a1f0cc9adf0bc20049a0ac1b5 to your computer and use it in GitHub Desktop.

Revisions

  1. vaskaloidis renamed this gist Jan 7, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. vaskaloidis renamed this gist Jan 7, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. vaskaloidis created this gist Jan 4, 2021.
    20 changes: 20 additions & 0 deletions ngrok_demo.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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