Why am I getting an error when calling API from Shopify liquid?

Why am I getting an error when calling API from Shopify liquid?

Mohit_garg
Shopify Partner
15 0 1

I am calling api from theme extension app when I am calling it shows
me this error

Session was not valid. Redirecting to
/api/auth?shop={{shopName}}.myshopify.com | {shop: {shopName}}.myshopify.com}
[shopify-api/ERROR] Missing Authorization header, was the request made
with authenticatedFetch? | {isOnline: false}

Until tomorrow it is working fine can you help me to solve this?
I have given proxy url :-

Subpath prefix : apps
Subpath: review-add
proxy-url : https://813c-2405-201-5c25-c00f-ad93-b7cd-2c23-7ee0.ngrok-free.app/api/review/product


Calling api like this
const fetchOptions = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(obj)
};

await fetch("/apps/review-add/reviewcall", fetchOptions);

and receiving like this

app.post("/api/review/product/reviewcall", async (_req, res) => {
try {
const obj = {
shop : _req.query.shop,
product_id : _req.body.id,
email : _req.body.mail,
author : _req.body.name,
rating: _req.body.rating,
title: _req.body.title,
description: _req.body.message,
reply: "adnajsnd"
}

const newReview = new ReviewModel(obj);
await newReview.save();
res.status(200).send();
} catch (error) {
console.log(error)
res.status(400).send();
}
});
Please help me regarding this error
Thanking you

 

 

 

 

Replies 2 (2)

devleoppersf
Shopify Partner
7 0 2

Not possible from liquid , i have already try that , should use CURL PHP , for security rasons shopify doesnt allow that 

Mohit_garg
Shopify Partner
15 0 1

It allows 😞