I recently started a new project and took the opportunity to try Rails 6 RC. The big take away so far has been the introduction of Webpacker as the default JavaScript bundler. We now have a cleaner way to import external libs like JQuery in our projects.

I tend to test mobile stuff locally by connecting to my laptop from the device via Ngrok but was greeted with the following error message.

To allow requests to hostname, add the following to your environment configuration:

config.hosts « “hostname”

Rails 6 has added middleware that guards against DNS rebinding attacks.

To get around this error, you need to set the hosts in the environment config (development.rb).

config.hosts = '1d9sfs33ed0.ngrok.io'

or

config.hosts = ['1d9sfs33ed0.ngrok.io', 'localhost']

In theory, you shouldn’t have to set hosts in production.

If you have multiple hosts that keep changing, you might consider clearing the hosts altogether.

config.hosts.clear