App proxy with custom storefront on local

App proxy with custom storefront on local

luszym
Shopify Partner
4 0 3

Hello there,

i've a custom app based on remix run (v2) and a headless storefront also on remix run (v2). Now the storefront communicates with the custom app using app proxy `/apps/custom-app`. When request is executed from storefront its passed to custom app, then authenticated using shopify appProxy method, example

 

headless storefront

fetch('/apps/custom-app/api/users')
   .then((response) => response.json())
.then((users) => {
console.log(users);
});

 

custom app, file routes/api.users.tsx

export async function loader(event: LoaderFunctionArgs) {
     const { session } = await authenticate.public.appProxy(event.request);

     // request authenticated, continue 
}

this works good on production, but now...

 

Q: I would like to use the app proxy when developing the storefront on local, how to do that?

Q: If it's not possible how to sign the request that goes directly to custom app so its authenticated with appProxy?

Replies 0 (0)