LoginSignup
1
0

More than 5 years have passed since last update.

GraphQL (graphiql-rails) をサブディレクトリで動かす方法

Posted at

開発環境では動くのにデプロイしたら動かないので調べたら graphiql-rails がサブディレクトリを考慮してくれていないためでした。

とりあえず次のように ActionController::Base.relative_url_root を自力で指定したら動きました。

config/routes.rb
Rails.application.routes.draw do
  mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "#{ActionController::Base.relative_url_root}/graphql"
  post "/graphql", to: "graphql#execute"
end

通常は ActionController::Base.relative_url_root は空なので常に上のように書いておいても問題ありません。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0