Sure, first you need to follow the instructions in Add an app proxy.
Then when processing the request in your Shopify app code inside web/index.js, you can do the signature validation and access the customer ID like:
/* You'll need to first install the shopify-application-proxy-verification npm library for this import statement to work. */
import { verifyAppProxyHmac as queryHasValidSignature } from 'shopify-application-proxy-verification';
/* The existing code in index.js will be here. */
/* Process requests coming to any endpoint of your choosing. */
app.all("/your/endpoint", async (req, res) => {
if (!queryHasValidSignature(req.query, process.env.SHOPIFY_API_SECRET)) {
return res.status(403).json({ errorMessage: 'Request was not correctly signed by Shopify' });
}
const customerId = req.query.logged_in_customer_id
if (customerId?.length === 0) {
const errorMessage = 'Please log in before hitting endpoint'
return res.status(401).json({ errorMessage });
});
/* Then, continue processing the request as needed. */
})