From c5f49ef1c10a16213defbf7591e5c448da15530d Mon Sep 17 00:00:00 2001 From: Paulo Margarido <64600052+paulomarg@users.noreply.github.com> Date: Mon, 27 Feb 2023 13:33:55 -0500 Subject: [PATCH 1/3] Add proxy instructions for non-API routes In development mode, the frontend runs on a separate process, and proxies requests to the backend. By default, that only happens for paths under `/api`, under the assumption that the app is a single-page application. When adding backend routes, it's important to remember that we need to add proxy exceptions too. This PR adds a comment to the routes file to help remind folks about the proxy rules. --- web/config/routes.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/config/routes.rb b/web/config/routes.rb index 73d657b..61076bc 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -6,8 +6,11 @@ mount ShopifyApp::Engine, at: "/api" get "/api", to: redirect(path: "/") # Needed because our engine root is /api but that breaks FE routing - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + # If you are adding routes outside of the /api path, remember to also add a proxy rule for + # it in web/frontend/vite.config.js + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + get "/api/products/count", to: "products#count" get "/api/products/create", to: "products#create" From b4eca5efc15dd69ae04ae473aecd4291f4d48a2d Mon Sep 17 00:00:00 2001 From: Paulo Margarido <64600052+paulomarg@users.noreply.github.com> Date: Mon, 27 Feb 2023 13:35:43 -0500 Subject: [PATCH 2/3] Update routes.rb --- web/config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/config/routes.rb b/web/config/routes.rb index 61076bc..2bb24b8 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -7,7 +7,7 @@ get "/api", to: redirect(path: "/") # Needed because our engine root is /api but that breaks FE routing # If you are adding routes outside of the /api path, remember to also add a proxy rule for - # it in web/frontend/vite.config.js + # them in web/frontend/vite.config.js # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html From 104de9ce4d784f86328e3d2deb1632fcdb06bba3 Mon Sep 17 00:00:00 2001 From: Paulo Margarido <64600052+paulomarg@users.noreply.github.com> Date: Mon, 27 Feb 2023 13:39:18 -0500 Subject: [PATCH 3/3] Update routes.rb --- web/config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/config/routes.rb b/web/config/routes.rb index 2bb24b8..23f33a8 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -10,7 +10,7 @@ # them in web/frontend/vite.config.js # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - + get "/api/products/count", to: "products#count" get "/api/products/create", to: "products#create"