Skip to main content

App proxy
object

The authenticate.public.appProxy function validates app proxy requests made by Shopify, and returns a context to enable querying Shopify APIs.

Anchor to authenticate.public.appProxy
authenticate.public.appProxy()

Authenticates requests coming from Shopify app proxies.

Request
required

Promise< | >
Was this section helpful?

Get your app's data using an offline session for the shop that made the request.

Was this section helpful?

Using the session object

app/routes/**\/.ts

import { json } from "@remix-run/node";
import { authenticate } from "../shopify.server";
import { getMyAppModelData } from "~/db/model.server";

export const loader = async ({ request }) => {
const { session } = await authenticate.public.appProxy(request);
return json(await getMyAppModelData({shop: session.shop));
};

Use the admin object to interact with the REST or GraphQL APIs.

Was this section helpful?

Interacting with the Admin API

app/routes/**\/.ts

import { json } from "@remix-run/node";
import { authenticate } from "../shopify.server";

export async function action({ request }: ActionArgs) {
const { admin } = await authenticate.public.appProxy(request);

const response = await admin.graphql(
`#graphql
mutation populateProduct($input: ProductInput!) {
productCreate(input: $input) {
product {
id
}
}
}`,
{ variables: { input: { title: "Product Name" } } }
);

const productData = await response.json();
return json({ data: productData.data });
}

Use the storefront object to interact with the GraphQL API.

Was this section helpful?

Interacting with the Storefront API

app/routes/**\/.ts

import { json } from "@remix-run/node";
import { authenticate } from "../shopify.server";

export async function action({ request }: ActionArgs) {
const { admin } = await authenticate.public.appProxy(request);

const response = await storefront.graphql(`{blogs(first: 10) { edges { node { id } } } }`);

return json(await response.json());
}

Use the liquid helper to render a Response with Liquid content.

Was this section helpful?

Rendering liquid content

app/routes/**\/.ts

import {authenticate} from "~/shopify.server"

export async function loader({ request }) {
const {liquid} = authenticate.public.appProxy(request);

return liquid("Hello {{shop.name}}")
}