Flutter Android API requests return a JavaScript challenge instead of JSON

Website URL

https://dahtor.gt.tc/

Error Message

The API root returns {“name”:“Dokhtor API”,“status”:“ok”}. But my Flutter app needs the data endpoint https://dahtor.gt.tc/index.php/api/governorates. Please confirm the correct API URL and allow Flutter Android requests to return JSON.

Other Information

This is a PHP API for a Flutter mobile app. Please allow direct HTTPS requests to /index.php/api/* and return application/json. If possible, disable the JavaScript/browser challenge for these API paths. The admin dashboard should remain protected.

Welcome to the InfinityFree community forum! Good to have you here.

  • Most people answering here are volunteers. They’re often the fastest source of help. Admin (the only staff member) checks in about once a day for issues on our end.
  • Volunteers can’t see your account or website. Share what you actually see, like error messages and what happens when you try something. That’s more useful than your theory of what’s wrong.
  • AI tools often get InfinityFree wrong. If a volunteer’s advice differs from what an AI told you, please try the volunteer’s suggestion first.
  • Solving an issue is a joint effort. Try the suggestions you get and report back what happened.

Beep boop, I’m a bot! I dug through the forum to get you started. I sometimes get things wrong though, so do with this what you will until a human has a look.

Unfortunately, this can’t be turned off. The URL is fine, but the check will block your Flutter app.

Every free hosting account has a browser security check. It only lets through clients that can run JavaScript and keep cookies. A Flutter app’s HTTP client can’t do either. It gets a short HTML page that loads /aes.js instead of your JSON. The guide says the check covers every URL on the site. It can’t be turned off for one path, such as /index.php/api/*, or for one user agent or IP address. Using your own domain doesn’t change that. The API root probably looks fine because you opened it in a browser, which passes the check.

So your Flutter app can’t call a PHP API hosted on a free InfinityFree account. The guide’s own list of what doesn’t work includes Android apps and REST APIs. Its page on mobile apps says the options are to move to premium hosting, which doesn’t have this restriction, or to redesign the app so it doesn’t fetch data directly from your free site.

Here is the guide on the security system:

Here is the article on mobile apps: