chore: ability to run Chatwoot as API only server (#2344)
- Ability to run chatwoot as an API only server - Removes action cable testing gem since it is merged to rails 6
This commit is contained in:
@@ -76,4 +76,13 @@ Rails.application.configure do
|
||||
Bullet.bullet_logger = true
|
||||
Bullet.rails_logger = true
|
||||
end
|
||||
|
||||
# ref: https://github.com/cyu/rack-cors
|
||||
config.middleware.insert_before 0, Rack::Cors do
|
||||
allow do
|
||||
origins '*'
|
||||
resource '/packs/*', headers: :any, methods: [:get, :options]
|
||||
resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'uid', 'expiry']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -110,10 +110,14 @@ Rails.application.configure do
|
||||
|
||||
# font cors issue with CDN
|
||||
# Ref: https://stackoverflow.com/questions/56960709/rails-font-cors-policy
|
||||
# ref: https://github.com/cyu/rack-cors
|
||||
config.middleware.insert_before 0, Rack::Cors do
|
||||
allow do
|
||||
origins '*'
|
||||
resource '/packs/*', headers: :any, methods: [:get, :options]
|
||||
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('CW_API_ONLY_SERVER', false))
|
||||
resource '*', headers: :any, methods: :any, expose: ['access-token', 'client', 'uid', 'expiry']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,14 +8,19 @@ Rails.application.routes.draw do
|
||||
token_validations: 'devise_overrides/token_validations'
|
||||
}, via: [:get, :post]
|
||||
|
||||
root to: 'dashboard#index'
|
||||
## renders the frontend paths only if its not an api only server
|
||||
if ActiveModel::Type::Boolean.new.cast(ENV.fetch('CW_API_ONLY_SERVER', false))
|
||||
root to: 'api#index'
|
||||
else
|
||||
root to: 'dashboard#index'
|
||||
|
||||
get '/app', to: 'dashboard#index'
|
||||
get '/app/*params', to: 'dashboard#index'
|
||||
get '/app/accounts/:account_id/settings/inboxes/new/twitter', to: 'dashboard#index', as: 'app_new_twitter_inbox'
|
||||
get '/app/accounts/:account_id/settings/inboxes/new/:inbox_id/agents', to: 'dashboard#index', as: 'app_twitter_inbox_agents'
|
||||
get '/app', to: 'dashboard#index'
|
||||
get '/app/*params', to: 'dashboard#index'
|
||||
get '/app/accounts/:account_id/settings/inboxes/new/twitter', to: 'dashboard#index', as: 'app_new_twitter_inbox'
|
||||
get '/app/accounts/:account_id/settings/inboxes/new/:inbox_id/agents', to: 'dashboard#index', as: 'app_twitter_inbox_agents'
|
||||
|
||||
resource :widget, only: [:show]
|
||||
resource :widget, only: [:show]
|
||||
end
|
||||
|
||||
get '/api', to: 'api#index'
|
||||
namespace :api, defaults: { format: 'json' } do
|
||||
|
||||
Reference in New Issue
Block a user