Questions and discussions about using the Shopify CLI and Shopify-built libraries.
I'm having a lot of trouble trying to figure out how to connect a form in the Shopify Storefront with my App. The data from the form will be used to create a metafield. One answer here said that you can either send the information over ajax to a URL endpoint created in your private app or use an App Proxy. I don't fully understand how to do either of these things yet.
The main thing I'm confused about is what URL I should use for the action of the form. For now, I'm just hosting the app on my computer with ngrok, so would I use the link it provides when I run Shopify App Serve plus the router path?
<form action="https://[randomnumbers].ngrok.io/foobar">
<!-- form stuff -->
</form>
Or would the store need to be part of the URL?
And then on the server side (I created the app with the Shopify CLI), would I make a new route in the server/server.js file? Something like this:
router.post("/foobar", async (ctx) => {
// create metafield here
}
If anyone knows of any tutorials going over this, that would be very helpful.