Issue with better_errors in a Sinatra app in GitHub Codespace environment
Closed this issue · 1 comments
I can run better_errors
in my local dev environment, but when I try to do the same on a GitHub Codespace cloud IDE, I still get the classic error page. I have tried a number of different images in the devcontainer.json
file that Codespaces builds on, but nothing is working.
Per the documentation, I added to my Gemfile
:
group :development do
gem "better_errors"
gem "binding_of_caller"
end
And to the top of the Sinatra app.rb
:
require "better_errors"
configure :development do
use BetterErrors::Middleware
BetterErrors.application_root = __dir__
end
But I always get the same classic error page rather than the better_errors
version.
These steps appear to work fine in a Rails app, but not with Sinatra. Are there additional gem requirements I am missing? Has anyone else had an issue with better_errors
in a GitHub Codespace IDE?
Thanks in advance!
Edit: I'm trying to follow the stack trace of an error and I note that this line in middleware.rb
is called out:
https://github.com/BetterErrors/better_errors/blob/master/lib/better_errors/middleware.rb#L62
I'm not sure what the issue is with that @app.call env
line in Sinatra.
Okay, finally traced the issue using this SO post: https://stackoverflow.com/questions/27117443/why-doesnt-better-errors-work-on-cloud-9-ide
Fix for Codespaces and potentially all other Cloud IDEs:
-
echo "export TRUSTED_IP='0.0.0.0/0.0.0.0'" >> ~/.bashrc
-
source ~/.bashrc
-
In the configuration:
use BetterErrors::Middleware
BetterErrors.application_root = __dir__
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP']