Shopify app proxy returns 302 status code and redirect /auth/login

I have a shopify app proxy so that I can get data from my db and populate it in the app theme extension. Below is my liquid file and proxy file. Everything works good, the console.log is printed when I call the function but in the frontend I keep getting the below response:

Request URL: https://kitapp-testapp.myshopify.com/apps/badge

Request Method: GET

Status Code: 302 Found

Remote Address: [2620:127:f00f:e::]:443

Referrer Policy: strict-origin-when-cross-origin

location: /auth/login