2017-11-27 19 views
0

私はmount_devise_token_auth_forを使用して、api経由でユーザ認証を実装します。Rails "/ api/auth/sign_in"プロダクションサーバで404エラー

http://localhost:3000/api/auth/sign_inを開発モードで呼び出すとうまくいきます。ただし、URLがhttp://www.mywebsiteaddress.com/api/auth/sign_inの場合、プロダクションサーバーでは機能しません。プロダクションサーバーからの応答は、「探していたページが存在しません」です。

私はウェブサイトが展開されているAWS EC2でproduction.logをチェックし、このエラーメッセージ

D, [2017-11-24T20:37:03.729410 #22965] DEBUG -- : ^[[1m^[[36mActiveRecord::SchemaMigration Load (1.3ms)^[[0m ^[[1mSELECT "schema_migrations".* FROM "schema_migrations"^[[0m 
I, [2017-11-24T20:37:14.914903 #23467] INFO -- : Started GET "/" for 172.218.118.129 at 2017-11-24 20:37:14 +0000 
I, [2017-11-24T20:37:14.970919 #23467] INFO -- : Processing by StaticPagesController#landing as HTML 
I, [2017-11-24T20:37:15.020589 #23467] INFO -- : Rendered static_pages/landing.html.erb within layouts/application (41.2ms) 
I, [2017-11-24T20:37:15.024040 #23467] INFO -- : Rendered layouts/_footer.html.erb (1.0ms) 
I, [2017-11-24T20:37:15.024283 #23467] INFO -- : Completed 200 OK in 53ms (Views: 47.3ms | ActiveRecord: 0.0ms) 
I, [2017-11-24T20:37:53.618896 #23467] INFO -- : Started OPTIONS "/api/auth/sign_in" for 172.218.118.129 at 2017-11-24 20:37:53 +0000 
F, [2017-11-24T20:37:53.621125 #23467] FATAL -- : 
ActionController::RoutingError (No route matches [OPTIONS] "/api/auth/sign_in"): 
    actionpack (4.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
    actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 
    railties (4.2.2) lib/rails/rack/logger.rb:38:in `call_app' 
    railties (4.2.2) lib/rails/rack/logger.rb:20:in `block in call' 
    activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `block in tagged' 
    activesupport (4.2.2) lib/active_support/tagged_logging.rb:26:in `tagged' 
    activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `tagged' 
    railties (4.2.2) lib/rails/rack/logger.rb:20:in `call' 
    request_store (1.3.1) lib/request_store/middleware.rb:9:in `call' 
    actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:in `call' 
    rack (1.6.5) lib/rack/methodoverride.rb:22:in `call' 
    rack (1.6.5) lib/rack/runtime.rb:18:in `call' 
    activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 
    rack (1.6.5) lib/rack/sendfile.rb:113:in `call' 
    railties (4.2.2) lib/rails/engine.rb:518:in `call' 
    railties (4.2.2) lib/rails/application.rb:164:in `call' 
    puma (3.6.2) lib/puma/configuration.rb:225:in `call' 
    puma (3.6.2) lib/puma/server.rb:578:in `handle_request' 
    puma (3.6.2) lib/puma/server.rb:415:in `process_client' 
    puma (3.6.2) lib/puma/server.rb:275:in `block in run' 
    puma (3.6.2) lib/puma/thread_pool.rb:116:in `block in spawn_thread' 

が、これは私のルートの設定です:

namespace :api, defaults: { format: :json } do 
    scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do #namespace for the controller is :v1 
     mount_devise_token_auth_for 'User', at: 'auth' 
     resources :tour_types, only:[:index, :show] 
     resources :routes, only: [:show] 
     resources :cruises, only: [:index, :show] 
     post "inquiry/cruiseinquirycreate" => 'contacts_api#cruise_inquiry_create' 
    end 
    end 
routes.rbを

答えて

0

プロダクションサーバーではクロスソースリソース共有(CORS)が許可されていないため、Gemラックコルが追加され、関連する設定がセットアップされています。

関連する問題