Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

Hitting a backend in an embedded application

akatcha
Tourist
7 1 1

Hello,

 

I'm trying to hit a backend application from my front-end in an embedded application.  The backend has a database that the frontend is meant to query.  

 

I'm building a nodejs backend with reactjs front-end.

If the frontend is trying to hit an endpoint with a GET example `/conversations`.  The nodejs application always responds with a 404 Not found.  I've added console.log statements to the backend and I know its processing requests.    

Are requests to a nodejs backend required to have some header or something special to avoid the Not Found error?

 

Thank you.

Reply 1 (1)

AndyPicamaze
Explorer
41 1 15

Hi @akatcha 

Do you use Koa? I believe Koa's default response code is 404. You need to set it explicitly:

router.get('*', verifyRequest(), async (ctx) => {
      await handle(ctx.req, ctx.res);
      ctx.respond = false;
      ctx.res.statusCode = 200;
    });

 

https://apps.shopify.com/picamaze
Animated watermarks for product images and ads