Hi everyone,
I’m working on a Shopify Remix app and using App Proxy to send requests from the Shopify storefront to my app server. However, I’m getting the error:
“Query does not contain a signature value”
I understand that Shopify App Proxy requests using a signature parameter, and I need to validate this signature on my server using the app’s shared secret.
Could someone please guide me on:
How to correctly generate and validate the App Proxy signature in a Remix (Node.js) environment?
Do I need to use signature for verification?
How should I handle the query parameters before generating the hash?
Any code examples or best practices for handling this in a Remix app would be greatly appreciated!
Hi @greeshma
did you use authentication for app proxy at your api (loader or action)?
const { admin } = await authenticate.public.appProxy(request);
@BiDeal-Discount
I’m using an App Proxy to fetch the variant ID of a product. I have this JavaScript code in my Liquid theme to make a request to my custom Remix App route:
// Fetch variant ID dynamically
fetch(/apps/wishlist?productId=${productId}&shop=${shop})
.then(response => response.json())
.then(data => {
if (data && data.variantId) {
wishlistButton.dataset.variantId = data.variantId;
}
})
.catch(error => console.error(“Error fetching variant ID:”, error));
Here’s my loader function inside the Remix app
import { json } from “@remix-run/node”;
import { authenticate } from ‘../shopify.server’;
export async function loader({ request }) {
const url = new URL(request.url);
const productId = url.searchParams.get(“productId”);
const formattedId = gid://shopify/Product/${productId};
const { storefront } = await authenticate.public.appProxy(request);
const response = await storefront.graphql(
query getProduct($id: ID!) { node(id: $id) { __typename ... on Product { id title variants(first: 1) { edges { node { id title } } } } } },
{ variables: { id: formattedId } }
);
const jsonResponse = await response.json();
let variantId = null;
if (
jsonResponse?.data?.node?.__typename === “Product” &&
jsonResponse.data.node.variants.edges.length > 0
) {
const fullVariantId = jsonResponse.data.node.variants.edges[0].node.id;
variantId = fullVariantId.split(“/”).pop();
}
return json({ variantId }, {
headers: {
“Access-Control-Allow-Origin”: “*”,
},
});
}
How do I pass and verify the signature parameter in the frontend API call for the App Proxy? Do I need to append the signature manually in the fetch call?