4

When I change my app (Spree Commerce) to production mode, the app is running fine, but when I want to go to "/admin" page the server throws me "This webpage is not available" in a chrome browser. Also, I don't know if this is normal, but when the server throws me the error, the server changes the url from

http://localhost:3000/ to https://localhost/

Can anyone help? Do I have to do something to the admin and log-in pages for them to work properly? This is my first time developing with Rails.

As an example, these are the logs that are produced when I try to go to http://localhost:3000/login

I, [2014-06-19T17:09:17.368486 #4208]  INFO -- : Started GET "/login" for 127.0.0.1 at 2014-06-19 17:09:17 -0500
I, [2014-06-19T17:09:17.531531 #4208]  INFO -- : Processing by Spree::UserSessionsController#new as HTML
I, [2014-06-19T17:09:17.697253 #4208]  INFO -- : Redirected to https://localhost/login
I, [2014-06-19T17:09:17.697444 #4208]  INFO -- : Filter chain halted as #<Proc:0x00000004f9a0c0@/home/angel/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_controller/metal/force_ssl.rb:65> rendered or redirected
I, [2014-06-19T17:09:17.697662 #4208]  INFO -- : Completed 301 Moved Permanently in 166ms (ActiveRecord: 0.0ms)`
8
  • Post your routes and your get request with the error. Commented Jun 19, 2014 at 21:48
  • 1
    Also check if you are using ssl in the production environment! Commented Jun 19, 2014 at 21:48
  • I have "# config.force_ssl = true" with the comment symbol and this are the logs when I try to enter http://localhost:3000/login" I'm going to edit my question above Commented Jun 19, 2014 at 22:08
  • My guess is that the environment production you are using is configured to use ssl, that's why the url is changing in localhost. You have to disable it. If the pasted ssl is from development it's ok, if it's from production how are you running the server? rails -s ENV -e production? Commented Jun 19, 2014 at 22:11
  • first I did export RAILS_ENV=production then I did the migrations for the production database. I change the line config.force_ssl = true to false in production.rb but the server is still redirecting me to https Commented Jun 19, 2014 at 22:16

2 Answers 2

12

Install gem to avoid this problem:

https://github.com/spree/spree_auth_devise

Someone had this problem before:

Spree: Turning off SSL redirects /admin back to site

Also:

I had the same issue fixed this by adding:

Creating a file:

../config/initilizers/spree.rb

Spree.config do |config|
  config.allow_ssl_in_production = false #This line
end

Seems to work.

2
  • I have that gem already installed, it seems that Spree is forcing me the SSL option, but I don't know where to change that option. Commented Jun 19, 2014 at 22:38
  • What about the initializer I pasted? Commented Jun 19, 2014 at 22:39
1

You just need to set allow_ssl_in_development_and_test to false in spree initializer.

initializers/spree.rb

Spree.config do |config|
  #...
  config.allow_ssl_in_development_and_test = false
  #...
end

Note: SSL requirement is removed in Spree 3.0 Check release note here

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.