Issue summary
Before opening this issue, I have done the following:
My shopify app needs to have a separate admin section where our admin will be able to handle our customers data, so I planned to namespace all the ShopifyApp with something like /shopify/ and leave the top level routes for our internal dashboard so I tried to wrap all the routes created by the rials template in a namespace like:
# frozen_string_literal: true
Rails.application.routes.draw do
namespace :shopify do
root to: "home#index"
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
scope path: :api, format: :json do
# POST /api/products and GET /api/products/count
resources :products, only: :create do
collection do
get :count
end
end
namespace :webhooks do
post "/app_uninstalled", to: "app_uninstalled#receive"
post "/app_scopes_update", to: "app_scopes_update#receive"
post "/customers_data_request", to: "customers_data_request#receive"
post "/customers_redact", to: "customers_redact#receive"
post "/shop_redact", to: "shop_redact#receive"
end
# Health check routes
end
mount ShopifyApp::Engine, at: "/api"
get "/api", to: redirect(path: "/") # Needed because our engine root is /api but that breaks frontend routing
# If you are adding routes outside of the /api path, remember to also add a proxy rule for
# them in web/frontend/vite.config.js
# Any other routes will just render the react app
match "*path" => "shopify/home#index", via: %i[get post]
end
get "health", to: "health#index"
get "health/detailed", to: "health#detailed"
root to: "dashboard#index"
end
Checking the routes with rails route, I noticed that all the routes generated by the ShopifyApp engine are still not namespace. I spent several hours trying to set up the config.root_url and the at: "/api" in the engine mount to various properties in the engine initialisers, but this didn't help. Then I noticed that some of the paths are even hardcoded and not configurable.
|
get "logout" => :destroy, :as => :logout |
|
get "patch_shopify_id_token" => :patch_shopify_id_token |
Expected behavior
All the routes generated by the engine should be namespaced.
Actual behavior
all the routes are not namespaced
Steps to reproduce the problem
- Add a namespace around the mount engine in the
config/routes.rb
- Run the command
rails routes
Debug logs
// Paste any relevant logs here
Issue summary
Before opening this issue, I have done the following:
shopify_appversion:22.5.23.3.0log_level: :debugin my configuration, if applicableMy shopify app needs to have a separate admin section where our admin will be able to handle our customers data, so I planned to namespace all the ShopifyApp with something like
/shopify/and leave the top level routes for our internal dashboard so I tried to wrap all the routes created by the rials template in a namespace like:Checking the routes with
rails route, I noticed that all the routes generated by the ShopifyApp engine are still not namespace. I spent several hours trying to set up theconfig.root_urland theat: "/api"in the engine mount to various properties in the engine initialisers, but this didn't help. Then I noticed that some of the paths are even hardcoded and not configurable.shopify_app/config/routes.rb
Lines 10 to 11 in bf3ab7e
Expected behavior
All the routes generated by the engine should be namespaced.
Actual behavior
all the routes are not namespaced
Steps to reproduce the problem
config/routes.rbrails routesDebug logs