If you try to use ngrok with Rails 6 you will find that whatever tries to connect to your app via the ngrok url will receive the following error:
To allow requests to 567d76da1d3.ngrok.io, add the following to your environment configuration: config.hosts << “567d76da1d3.ngrok.io”
This is because Rails 6 introduces a little extra security to prevent attacks and will only allow 0.0.0.0 and localhost to connect. To allow a different host to access the app you simply need to update your
config/environments/development.rb file and add one of the following lines:
config.hosts = nil
config.hosts << /[a-z0-9]+\.ngrok\.io/
config.hosts << "567d76da1d3.ngrok.io"
The former will allow all hosts. For most people this is probably fine. But if you require more security you can use the second approach and provide a regexp to allow only ngrok addresses. The last approach provides a hardcoded host which is good when the host rarely changes.