Hi guys,
Please help me to get through the wall.
I’m a newbie to Shopify app. I’ve used yarn create @shopify/app with Node. After that, I made the Theme App Extension too.
I have watched too many videos about proxies, including the video by Liz Kenyon: https://www.youtube.com/watch?v=ZiugtHDctFk&ab_channel=ShopifyDevs
I followed her instructions, as well as this article from @Brandon15 : https://community.shopify.com/c/shopify-apis-and-sdks/404-error-with-app-proxy-in-node/m-p/1624693#M80700
Here is my proxy configuration:
-
Subpath prefix: apps
-
Subpath: my_app
-
Proxy URL: https://fbad-210-245-34-240.ap.ngrok.io/
Notes: If I make the proxy url with “api” at the end like this (similar to the video by Liz Kenyon): https://fbad-210-245-34-240.ap.ngrok.io/api, it event worse. I don’t know why.
In the project extension, I used JavaScript to fetch data from my back-end app:
fetch("/apps/my_app/settings", { method: "GET" });
In the web directory (server side), I modify the index.js file to add just simple code:
app.use("/api/*", shopify.validateAuthenticatedSession());
app.use(express.json());
////// THIS IS MY NEW PROXY TEST HERE /////
app.get("/settings", (req, res) => {
console.log("======> I GOT THIS!");
const jsonObject = { content: "Proxy is working" };
res.send(jsonObject);
});
///// END OF PROXY TESTING ///
Whenever I try to use the front store, I always receive the returned HTML as a response.
I tried to to modify the index.js (in the web directory - server side) at the line “app.get(“/settings”, (req, res) => {“ to “app.get(“/api/settings”, (req, res) => {“ but no luck.
In all cases, I’ve never seen the log by this line**:**
console.log("======> I GOT THIS!");
It seemed that this endpoint would never be called.
I have been stuck on this for a few days now. Please, anyone with experience in proxy calling with Node, please help me.
Thank you so much.