How to Handle Multiple Endpoints in App Proxy for a Remix App?

Solved

How to Handle Multiple Endpoints in App Proxy for a Remix App?

greeshma
Shopify Partner
32 2 8

Hi everyone,

I’m building a Remix app that includes multiple endpoints. These endpoints are called from a Shopify theme app extension. Normally, this requires referencing the full app URL for each request. To avoid exposing the app URL, I decided to use Shopify’s App Proxy feature.

However, I’ve noticed that the App Proxy configuration in the Shopify Partner Dashboard allows only one proxy path. Since my app has multiple endpoints (e.g., /api/getWishlistData, /api/getProductDetails, etc.), I’m unsure how to handle this limitation.

Has anyone dealt with a similar situation?

  • Is there a way to route multiple endpoints through a single App Proxy path?

  • How do you structure your Remix app to handle these proxy requests correctly?

Any guidance or examples would be greatly appreciated!

Accepted Solution (1)

TechNinja
Shopify Partner
12 1 3

This is an accepted solution.

Hi there!

 

A simple way to work around the single App Proxy path limitation is to use an action query parameter on the proxy URL — and route your logic based on its value.

 

Example:

 

export async function loader({ request }: LoaderArgs) {
  const url = new URL(request.url);
  const action = url.searchParams.get('action');

  switch (action) {
    case 'getWishlistData':
      return json(await handleGetWishlistData());
    case 'getProductDetails':
      return json(await handleGetProductDetails());
    default:
      return new Response('Invalid action', { status: 400 });
  }
}

 

View solution in original post

Replies 2 (2)

TechNinja
Shopify Partner
12 1 3

This is an accepted solution.

Hi there!

 

A simple way to work around the single App Proxy path limitation is to use an action query parameter on the proxy URL — and route your logic based on its value.

 

Example:

 

export async function loader({ request }: LoaderArgs) {
  const url = new URL(request.url);
  const action = url.searchParams.get('action');

  switch (action) {
    case 'getWishlistData':
      return json(await handleGetWishlistData());
    case 'getProductDetails':
      return json(await handleGetProductDetails());
    default:
      return new Response('Invalid action', { status: 400 });
  }
}

 

Kyle_liu
Shopify Partner
437 55 80

Hi  @greeshma 

 

At present, Shopify app proxy does not support multiple endpoints, which can be determined by URL parameters

export const loader = async ({request, params}) => {
  const {admin} = await authenticate.admin(request);
  const topic = params.topic;
  switch (topic) {
    case "ORDERS_CREATE":
      orderEventEmitter.emit("order-create", payload);
      break;
    case "ORDERS_UPDATED":
      orderEventEmitter.emit("order-updated", payload);
      break;
    default:
  }
  ...
};
If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me Email Me Buy Me A Coffee