Why do I suddenly block the internal API?

$server = $_SERVER['HTTP_HOST'];
 $url = $server . "/tag-List.json";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
    ]);
    curl_setopt($ch, CURLOPT_POST, true);
    $response = curl_exec($ch);
    $data = json_decode($response, true);

It’s not called since the website failure before, and when it’s called via var_dump($data); it’s called an empty value, and when it’s called, it shows that the web has been moved. Why did you block calls from inside, not outside? It got complicated because you had to do it without an api call after you blocked it..
But if you go directly through that link, the request goes well

I was under the impression that this would never work to begin with. All automated requests to websites should be blocked, even those coming from your own website.

Maybe there is some context I’m missing, but the code you’ve shared seems to show that you’re just reading a JSON file. If so, why not just do a file_get_contents('tag-List.json') and read the file directly from the storage? That’s faster and safer than using cURL.

And if the tag-list.json isn’t a file but a PHP endpoint, perhaps you can just call the code internally? That’s also safer and faster than using cURL.

7 Likes

The reason I use API is for convenience. You can use DIR but it’s more convenient to call it in an API format. Also, I worked on User API before, but it was blocked and I had a hard time. I think it’s more convenient to call mysql multiple times using API

Whatever you think, the expected result is that the code above doesn’t work. It worked before is unexpected despite that you are expecting so.
Please follow what Admin told you to do.

6 Likes

I understand that it’s more convenient to just call the script over HTTP instead of trying to make clean functions you can import. However, please do be aware that if it does work, then you still get:

  • It’s much slower to do a HTTP request than include a file and call a PHP function.
  • It uses additional PHP processes, which increases server load and reducing the traffic capacity of your website.
  • There is security risk if the $_SERVER['HTTP_HOST'] value contains something different than your website domain, or the domain doesn’t resolve to your own website from the server. This could enable an attacker to inject their own data in your website.

But what you’re doing should never have been possible. I don’t know why it worked before. But I do know that our hosting is working as intended, so we will not change this behavior.

7 Likes

No, it cannot be inserted. The external API is blocked and it worked fine when calling inside, so please release it.

The reason why it’s slow is that it’s only slow when it’s loaded and it’s fast when it’s small.

Traffic is also reduced when reading web files, so it is no different from API.

Is this line joke to you?

We are not asking for reasons. We are saying no.

6 Likes

To state again very clearly:

This was never supposed to be possible in the first place, and we are not going to make it possible.

What you were doing was possible because of a bug, and that bug has now been fixed (by accident or on purpose). We will not reintroduce the bug because you preferred the incorrect behavior.

I gave you a few alternatives to replicate the same functionality. How much effort it will be to implement depends on how your website works, but from a technical perspective, it’s absolutely possible.

Just because it’s fast enough for you doesn’t mean that it isn’t orders of magnitude slower than the alternative.

That is simply not true. Depending on your definition of “traffic”:

  • Bandwidth is measured by the data that’s transferred from your website to HTTP clients. Local file calls do not use bandwidth. Accessing your website with cURL and downloading data that way does use bandwidth.
  • Hits are the number of HTTP requests to your website. A single request produces one hit, regardless of what the server needs to generate the response. A request to a PHP script that accesses thousands of other files only produces one hit. The request to your PHP script generates a hit, but the request from the cURL call generates another hit. That means there are 2 hits per request which could have been just one.
5 Likes

Did I ask for outside? I want to be free to kill inside (website). Also, I have to make it again 24 hours a day because of that one.

That’s the thing: there is no difference between “inside” and “outside” requests. I think you just don’t understand how this works.

If you make a request to your own website, it comes in through the same software path as a request from elsewhere. That means that any bandwidth calculations, hits calculation, and security systems, all work exactly the same unless specific exceptions are added for internal traffic.

And those exceptions don’t exist, they have ever (deliberately) existed, and they will not be added. I have never heard of a hosting provider having such exceptions.

If you want to keep the request “inside”, then the way to do that is to not use cURL, and either read the file locally or call the PHP functions generating the data.

7 Likes

Inside: Callable only on my website
External: API calls from other websites

It makes no difference. Both of them are API calls, and will not work.

6 Likes

It’s unlimited traffic, so I didn’t call too much, and if it’s for the website, it includes an internal API

I understand your frustration. It’s upsetting when a bug is fixed and it breaks something that your website was reliant on.

But please understand that making an api call, wether internally or externally looks the same to the server, and was never meant to work. When you call the API through curl, it essentially goes to the internet and calls your api, so in thet respect it kind of is external.

Unfortunately in the time you’ve spent debating this here, you could have rewritten your code to work within the limitations.

Also infinity free doesn’t support unlimited traffic. It very specifically has a hits limit and CPU limit.

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.