내 앱에서 흥미로운 문제를 발견했습니다.
저는 루비 2.0과 함께 Rails 3을 사용하고 있습니다. 내 앱이 실행중인 프로덕션 서버와 다른 스테이징 서버가 이미 있습니다. 새로운 더 나은 것을 구성하고 있지만 Safari에만 문제가 있습니다.
Redirected to http://ip.server/
Completed 302 Found in 201.7ms (ActiveRecord: 0.0ms)
Started GET "/" for my.ip at 2014-10-13 08:17:18 +0200
Processing by DashboardController#index as HTML
Completed 401 Unauthorized in 1.2ms
Started GET "/user/sign_in" for my.ip at 2014-10-13 08:17:18 +0200
Processing by Devise::SessionsController#new as HTML
Rendered application/_field_errors.html.erb (0.0ms)
Rendered application/_field_errors.html.erb (0.0ms)
Rendered devise/sessions/new.html.erb within layouts/devise (2.3ms)
Completed 200 OK in 5.5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
네트워크 탭을 확인하면 다음을 볼 수 있습니다.
리소스로드 실패 : 서버가 401 (권한 없음) 상태로 응답했습니다.
처음에는 내 문제가 Devise에서 비롯된 것이라고 생각했지만 Google에서 확인한 결과 크로스 브라우저 문제
나는 Chrome에서 시도했고 작동합니다. AdBlock없이 또는 개인 탐색으로 시도했지만 여전히 Safari에서는 작동하지 않습니다.
편집하다:
두 가지 요청을했습니다. 하나는 Chrome에서, 다른 하나는 Safari에서 왔습니다. 유일한 차이점은 다음 줄입니다.
WARNING: Can't verify CSRF token authenticity
편집 2 :
나는 protect_from_forgery
내 줄 에 주석을 ApplicationController.rb
달았고 마침내이 오류 (CSRF에 관한)는 내 문제에 대한 책임이 없습니다.
여기에 Chrome과 Safari로 시도 할 때 스택이 있습니다.
Chrome 사용 :
Started POST "/user/sign_in" for my.ip at 2014-10-14 13:27:51 +0200
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"c86MNR4MCSbQWJiAjkGtgfgPMg5YirG1tqf/2vqdBWc=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}}
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = '[email protected]' LIMIT 1
(0.1ms) BEGIN
WARNING: User#current is nil, are you including SentientController on your ApplicationController?
(0.3ms) UPDATE `users` SET `last_sign_in_at` = '2014-10-14 11:26:45', `current_sign_in_at` = '2014-10-14 11:27:51', `sign_in_count` = 52, `updated_at` = '2014-10-14 11:27:51' WHERE `users`.`type` IN ('User::Admin') AND `users`.`id` = 1
(26.1ms) COMMIT
Redirected to http://server.ip/
Completed 302 Found in 135.6ms (ActiveRecord: 0.0ms)
Started GET "/" for my.ip at 2014-10-14 13:27:51 +0200
Processing by DashboardController#index as HTML
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
server.ip Rendered dashboard/index.html.erb within layouts/application (2.5ms)
Rendered application/_header.html.slim (57.6ms)
Rendered application/_sidebar.html.erb (48.1ms)
Rendered application/_page_header.html.slim (2.0ms)
Rendered application/_flash_messages.html.erb (0.5ms)
Rendered application/_footer.html.erb (0.8ms)
Completed 200 OK in 137.5ms (Views: 122.9ms | ActiveRecord: 5.1ms)
Safari 사용 :
Started POST "/user/sign_in" for my.ip at 2014-10-14 13:27:58 +0200
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"TWKhSxus5q46H9sZdEvMnzD52r0zA5phw/Pv7K+NKuY=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}}
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = '[email protected]' LIMIT 1
(0.1ms) BEGIN
(0.3ms) UPDATE `users` SET `last_sign_in_at` = '2014-10-14 11:27:51', `current_sign_in_at` = '2014-10-14 11:27:58', `sign_in_count` = 53, `updated_at` = '2014-10-14 11:27:58' WHERE `users`.`type` IN ('User::Admin') AND `users`.`id` = 1
(24.8ms) COMMIT
Redirected to http://server.ip/
Completed 302 Found in 138.2ms (ActiveRecord: 0.0ms)
Started GET "/" for my.ip at 2014-10-14 13:27:58 +0200
Processing by DashboardController#index as HTML
Completed 401 Unauthorized in 1.2ms
Started GET "/user/sign_in" for my.ip at 2014-10-14 13:27:58 +0200
Processing by Devise::SessionsController#new as HTML
Rendered application/_field_errors.html.erb (0.0ms)
Rendered application/_field_errors.html.erb (0.0ms)
Rendered devise/sessions/new.html.erb within layouts/devise (2.2ms)
Completed 200 OK in 5.2ms (Views: 3.7ms | ActiveRecord: 0.0ms)
문제 해결됨. 내 앱에서 오는 것이 아니라 DNS 리디렉션에서 나온 것입니다. 테스트를 위해 간단한 웹 리디렉션을 넣었고 DNS 리디렉션을 추가하는 것을 잊었습니다.
이제 모든 것이 완벽하게 작동합니다.
다른 사람에게 도움이되기를 바랍니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다