API call
Unanswered
Yacare Caiman posted this in #help-forum
Yacare CaimanOP
gm guys
In my NextJS app, I have a server I call through an API from the front end
This API itself calls a lot of APIs, and I noticed recently that some of the API does not work if I don't add this specific header (thks chatgpt)
This is how I used to call my
And now:
With the header, it works.
I mean... it works on localhost, but once I deploy the app on Vercel, it doesn't work
It is much harder to debug since I don't have the console to read the logs once hosted, how can I solve this?
In my NextJS app, I have a server I call through an API from the front end
This API itself calls a lot of APIs, and I noticed recently that some of the API does not work if I don't add this specific header (thks chatgpt)
This is how I used to call my
const response = await axios.get(chain.api_url, {
params: {
module: "account",
action: type,
address,
offset: sizeOffset, //Number of transaction (increase to 100 later)
sort: "desc",
apikey: chain.api_key,
},
});And now:
const response = await axios.get(chain.api_url, {
params: {
module: "account",
action: type,
address,
offset: sizeOffset, //Number of transaction (increase to 100 later)
sort: "desc",
apikey: chain.api_key,
},
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36",
},
});With the header, it works.
I mean... it works on localhost, but once I deploy the app on Vercel, it doesn't work
It is much harder to debug since I don't have the console to read the logs once hosted, how can I solve this?
12 Replies
Yacare CaimanOP
I noticed I can read the logs on vercel, but only some of them
is there a trick to have access to all the logs?
is there a trick to have access to all the logs?
I'm in pro but 4k limit...
useless
Asian paper wasp
I assume you know what a user agent is?
I don't know whether those APIs are controllable by you, but I know some API services will check for user agents to decide whether to proceed. e.g. prevent bot spamming. Not sure if that's the case for you.
I don't know whether those APIs are controllable by you, but I know some API services will check for user agents to decide whether to proceed. e.g. prevent bot spamming. Not sure if that's the case for you.
@Asian paper wasp I assume you know what a user agent is?
I don't know whether those APIs are controllable by you, but I know some API services will check for user agents to decide whether to proceed. e.g. prevent bot spamming. Not sure if that's the case for you.
Yacare CaimanOP
Tbh I'm not that familiar with the user agent
Those API have some settings, including an API KEY, so they shouldn't bother if I use them from a server or on local
Those API have some settings, including an API KEY, so they shouldn't bother if I use them from a server or on local
Asian paper wasp
User agents are typically injected automatically that contain info about the caller of the API.
Stuff like the OS, browser, browser version, whether it is a bot, etc.
That's why I'm wondering whether the API is explicitly blocking certain user agents
Stuff like the OS, browser, browser version, whether it is a bot, etc.
That's why I'm wondering whether the API is explicitly blocking certain user agents
@Asian paper wasp User agents are typically injected automatically that contain info about the caller of the API.
Stuff like the OS, browser, browser version, whether it is a bot, etc.
That's why I'm wondering whether the API is explicitly blocking certain user agents
Yacare CaimanOP
hmm I see
So how can I solve this?
So how can I solve this?
Asian paper wasp
Well, that's that API exactly?
this one
(i did not hide the key but i'll create another one no worries)
Asian paper wasp
Since this is a 3rd part API, you will need to contact the team for investigation. There is nothing you can do if you are sure if user agent is indeed the only thing making the differences