问题
I am following along with this Treehouse Build a Rails API course. I am using Cloud9 IDE which I think is related to the problem. The step I am stuck on is creating a new list via the API in the console.
At first I was receiving an error message saying "cannot render console" from the network. After googling this, I whitelisted the network in the development.rb file. The error message is different and so I believe I properly whitelisted it (or at least did something). But it does not have the desired effect and the error message seems to contradict itself.
Started POST "/api/lists" for 123.456.78.999 at 2015-09-14 14:53:33 +0000 Cannot render console from 123.456.78.999! Allowed networks: 123.456.78.999, 127.0.0.0/127.123.123.123, ::1
I've changed the numbers because I am not savvy about security. The point (and to me, the mystery) is that it says I can't render the console from a network that is apparently allowed (i.e., 123.456.78.999 === 123.456.78.999).
I would appreciate any advice on what could be the problem. I had no trouble following along with the tutorial until this step; the commands I entered led to the same result as in the videos.
This is the most recent command I've entered:
curl -i -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"title":"The Title will go here"}' https://myapp-me.c9.io/api/lists
Entering that URL instead of "localhost" has worked for me thus far but it could also be related to the problem.
Thank you for any clues and happy to post additional code if needed.
回答1:
please add in config/enviroments/development.rb
config.web_console.whitelisted_ips = '0.0.0.0/0.0.0.0'
回答2:
To whitelists 2 IPs > Consider this example:
config.web_console.whitelisted_ips = %w( 127.0.0.1 10.0.0.9 )
To whitelist an entire IP subnet > Consider this example:
config.web_console.whitelisted_ips = %w( 127.0.0.1 10.0.0.0/24 )
always add 127.0.0.1
, or else the local machine won't have access.
回答3:
Part of the problem is that you need to be within the "sudo su" shell in order to run Ruby on Rails applications. So, make sure that you run sudo su
and you become root. The second problem is that you MUST run your application on port 8080 so when you run the server make sure the -p 8080
flag is set:
bundle update
(optional)bundle install
(optional)sudo su
rails s -p 8080
- New terminal --> Preview --> Preview running application
来源:https://stackoverflow.com/questions/32568556/cloud9-rails-api-challenge-allowed-network-but-still-cannot-render-console