Hitting a backend in an embedded application

Highlighted
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.

0 Likes
Highlighted
Excursionist
38 1 8

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
1 Like