#API call

13 messages · Page 1 of 1 (latest)

alpine dirge
#

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

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?

thorn wedgeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

alpine dirge
#

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?

#

I'm in pro but 4k limit...

#

useless

ornate nimbus
#

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.

alpine dirge
ornate nimbus
#

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

alpine dirge
ornate nimbus
#

Well, that's that API exactly?