FROM CACHE - en_header

app_proxy in my rails app triggers second GET call with undefined" appended to the path.

theory3000
Shopify Partner
1 0 0

So I've got my Rails embedded app running well and am adding an app_proxy to serve some "profile" pages in my site frontend.   I've gotten the proxy settings and railsapp elements in place and working to display some data from my controller actions into a rendered liquid partial into my sites admin.   

When working into my subpath logic, like:  /a/community/profile/1 - I discovered some behavior that is breaking functionality with the calls triggering 2 GET calls instead of just the 1 that's expected.  the first GET is successful with a 200 return and the liquid rendering, but the another GET call is made from I don't know where or why with "undefined" appended to the url path before the params hash. 

so for example here's the behavior when loading the root path of the proxy

First successful 200 return:

 

Started GET "/community/?shop=foodguide-community-test.myshopify.com&path_prefix=%2Fa%2Fcommunity&timestamp=1628273930&signature=cf0b983cf4bafd4d80d4f8d84fabdfc4e388e1ebe92ab2ff30e71f28099fe263" for 35.184.83.180 at 2021-08-06 13:18:50 -0500
Cannot render console from 35.184.83.180! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by CommunityController#index as HTML
  Parameters: {"shop"=>"foodguide-community-test.myshopify.com", "path_prefix"=>"/a/community", "timestamp"=>"1628273930", "signature"=>"cf0b983cf4bafd4d80d4f8d84fabdfc4e388e1ebe92ab2ff30e71f28099fe263"}
  Shop Load (0.1ms)  SELECT  "shops".* FROM "shops" WHERE "shops"."shopify_domain" = ? LIMIT ?  [["shopify_domain", "foodguide-community-test.myshopify.com"], ["LIMIT", 1]]
  ↳ /Users/jasonferrantello/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.5/lib/active_record/log_subscriber.rb:98
  CACHE Shop Load (0.0ms)  SELECT  "shops".* FROM "shops" WHERE "shops"."shopify_domain" = ? LIMIT ?  [["shopify_domain", "foodguide-community-test.myshopify.com"], ["LIMIT", 1]]
  ↳ /Users/jasonferrantello/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.5/lib/active_record/log_subscriber.rb:98
  Shop Load (0.1ms)  SELECT  "shops".* FROM "shops" WHERE "shops"."shopify_domain" = ? ORDER BY "shops"."id" ASC LIMIT ?  [["shopify_domain", "foodguide-community-test.myshopify.com"], ["LIMIT", 1]]
  ↳ app/controllers/community_controller.rb:37
  User Load (0.1ms)  SELECT "users".* FROM "users"
  ↳ app/controllers/community_controller.rb:15
  Rendering community/index.liquid
  Rendered community/index.liquid (0.7ms)
Completed 200 OK in 8ms (Views: 3.6ms | ActiveRecord: 0.4ms)

 

THEN, the unprompted second get call coming in, yielding an error since there's no routing set up for that added "undefined" in the path

 

Started GET "/community/undefined?section_id=product-recommendations&limit=undefined&product_id=undefined&shop=foodguide-community-test.myshopify.com&path_prefix=%2Fa%2Fcommunity&timestamp=1628275735&signature=fd9007f23de11d363f7827b5e0002efc45f9b3cdf4d1139104b53e3b8bdfe5af" for 34.134.55.10 at 2021-08-06 13:48:54 -0500
Cannot render console from 34.134.55.10! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  
ActionController::RoutingError (No route matches [GET] "/community/undefined"):
  
actionpack (5.2.5) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:22:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.5) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.5) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.5) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.5) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.5) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.5) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.5) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.5) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.5) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
shopify_app (17.1.1) lib/shopify_app/middleware/jwt_middleware.rb:23:in `call_next'
shopify_app (17.1.1) lib/shopify_app/middleware/jwt_middleware.rb:11:in `call'
shopify_app (17.1.1) lib/shopify_app/middleware/same_site_cookie_middleware.rb:11:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.5) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.5) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.5) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
railties (5.2.5) lib/rails/engine.rb:524:in `call'
puma (3.12.6) lib/puma/configuration.rb:227:in `call'
puma (3.12.6) lib/puma/server.rb:706:in `handle_request'
puma (3.12.6) lib/puma/server.rb:476:in `process_client'
puma (3.12.6) lib/puma/server.rb:334:in `block in run'
puma (3.12.6) lib/puma/thread_pool.rb:135:in `block in spawn_thread'

 

 

This second phantom call is happening on any call happening in my app_proxy area, so it's definitely blocking my ability to dev the profile action in this controller as the last black that needs to convert to the :id I need is getting borked on that second call. 

Here's the controller:

 

class CommunityController < ApplicationController
  include ShopifyApp::EmbeddedApp
  include ShopifyApp::RequireKnownShop
  include ShopifyApp::ShopAccessScopesVerification
  # include ShopifyApp::AppProxyVerification

  def index
    set_session
    
     = params["id"]
    _origin = current_shopify_domain
    
    #   = User.first.email
    users = User.all
    @users = users.to_a.map(&:serializable_hash)   

    # binding.pry
    render layout: false, content_type: 'application/liquid'
  end

  def profile
    set_session

    id = params["id"].to_i
    # binding.pry

     = User.find(id)
    #  = user.to_a.map(&:serializable_hash)   


    render layout: false, content_type: 'application/liquid'
  end

  private

  def set_session
    current_shop = Shop.where(shopify_domain: current_shopify_domain).first
    session = ShopifyAPI::Session.new(domain: current_shopify_domain, token: current_shop.shopify_token, api_version: "2021-01")
    ShopifyAPI::Base.activate_session(session)
  end

end

 

 Routes.rb here

 

Rails.application.routes.draw do
  mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
  mount ShopifyApp::Engine, at: '/'

  devise_for :users

  root :to => 'home#index'
  
  get '/products', :to => 'products#index'
  get '/members', :to => 'members#index'
  # get '/admin', :to => 'admin#index'
  # get '/products/:id', to: 'products#show'

  get '/community', :to => 'community#index'
  get '/community/profile/:id', :to => 'community#profile'

end

 

 

What could be causing this consistent second phatom GET call and how can I stop it?

Thanks!

Replies 0 (0)