Problema con una ruta REST en una app de Shopify hecha con Koa: una petición fetch('/api/testRoute', { method: 'POST', body: JSON.stringify(...) }) funciona si la ruta no usa verifyRequest(), pero entonces no se obtienen correctamente datos como shop, body o session. Al añadir verifyRequest() en la ruta, la llamada falla y aparece un error en consola mostrado en una captura.
Puntos clave:
verifyRequest() es el middleware de Shopify que valida la sesión/token antes de permitir acceso a la ruta.
Se sugirió no aplicarlo directamente en el router.post(...), sino como middleware del servidor Koa con server.use(verifyRequest(...)).
Al probar eso, apareció un nuevo problema: ngrok redirected you too many times, impidiendo la instalación normal de la app.
Luego se recomendó cambiar el orden de los middlewares, colocando verifyRequest() después de createShopifyAuth(...) o después de registrar las rutas.
Estado actual: no hay confirmación de una solución final; la discusión queda abierta y centrada en el orden correcto de middlewares en server.js.
I am trying to create a Shopify application using the session tokens. I am using koa-router for creating a rest API route and I need to get the shop name and body content.
issue - If I call this route through the frontend WITHOUT verifyRequest, it works( i can get a response back) but I cannot get the shop name or body or anything else.
If I add the verifyRequest() and then try I get this in the app console
You should pass the verifyRequest() function to the server, not to the router. If you use Koa-auth, then most likely you use for the server also use Koa. Try this way:
const Koa = require(‘koa’);
const server = new Koa();
server.use(verifyRequest());