Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
How to make requests to Shopify's GraphQL Admin API with Vue & Apollo

I'm struggling to make requests to Shopify's GraphQL Admin API from my Vue app with the following setup:

src/lib/apolloClient.js

import { ApolloClient, createHttpLink, InMemoryCache } from "@apollo/client";

const httpLink = createHttpLink({
  uri: "https://{shop}.myshopify.com/admin/api/2021-07/graphql.json",
});

const cache = new InMemoryCache();

const apolloClient = new ApolloClient({
  link: httpLink,
  headers: {
    "X-Shopify-Access-Token": "{password}",
  },
  cache,
});

export default apolloClient;

src/main.js

import { createApp, provide, h } from "vue";
import "tailwindcss/tailwind.css"
import App from "./App.vue";
import apolloClient from "./lib/apolloClient";

createApp({
  setup() {
    provide(DefaultApolloClient, apolloClient);
  },
  render: () => h(App),
}).mount("#app");

I've been getting a CORS preflight error

No 'Access-Control-Allow-Origin' header is present on the requested resource

And when adding

fetchOptions: {
  mode: 'no-cors'
}

to my ApolloClient initialisation I get the following error:

unexpected end of JSON

I'm not too sure if my setup is completely not ideal or if I'm just missing a few configs.

I'm very new to Shopify Dev, but I'd like to build some extended functionality into my product listing pages with JavaScript. If anyone has got some experience with this, I'd appreciate some advice on how I should be architecting this, I'm not at all opposed to taking a completely different approach.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

That's by design, you aren't supposed to hit the Admin API on the front-end due to the security reasons, mainly due to the fact that you'd need to embed auth keys in your front-end bundle and that's always prone to disastrous effects.

You'll need to route those requests to a backend app of your own and that'll consume the API and proxy it to your front-end through App Proxies

See also:

Create product with Shopify Admin API

Can we get product by SKU using Shopify Storefront GraphQL API(NOT ADMIN)?

is that possible to use admin APIs in frontend directly in the store without app

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda