ruby-on-railsrubyngrok

How do I dynamically add my Ngrok tunnel to config.hosts in Rails 6?


I'm trying to whitelist my ngrok tunnel hostname in config.hosts but it changes every time I start Ngrok. Is there a way to get the public url of my Ngrok tunnel so that I don't have to use hosts.clear?


Solution

  • Simply configure config/environments/development.rb like so:

    Rails.application.configure do
    
      ...
    
      config.hosts << '.ngrok.io'
    end
    

    This will allow requests from any subdomain of ngrok.io.