Long time lurker, first time caller.
I just recently updated my failed payment application to Rails 6. Went to use Ngrok to test some webhoooks and got an interesting little error. Now, unless you specify a host in rails 6 everything except for localhost gets blocked. Great new security feature. Buuuut, what if I use ngrok regularly and don't have the paid version so I get a new address every time I run it? It's regex to the rescue.
Simply open config/environments/development.rb and then add config.hosts << /[a-z0-9]+\.ngrok\.io/super simple and awesome.
Thought I'd keep it short.
Have an awesome week.
Latest comments (10)
Thanks for the tip, but this regex doesn't cover all cases. I am using the below regex just to catch all possible hosts.
Yeah, I'm not regexpert so I'm sure there are spots that can be improved.
If you are on a regional domain e.g. ap.ngrok.io you can change this to
config.hosts << /[a-z0-9]+\.ap.ngrok\.io/Nice :)
You can also set
config.hosts = nilto disable the feature if you want to let it accept all domains.Ah yeah, didn't think of that.
Safer to do it your way. π
Haha, yeah.
Thanks for the tip
Thanks for the forum to share said tip!