When I submit my registration form, the POST request to /backend/register.php returns an HTML page containing aes.js and a __test cookie instead of JSON.
Opening the PHP endpoint directly works, but submitting the form using JavaScript fetch() returns the anti-bot HTML.
How can I fix this on InfinityFree hosting?
Thank you.
Other Information
The issue occurs when submitting the registration form using JavaScript fetch() with a POST request. The server returns an anti-bot HTML challenge instead of JSON. JavaScript is enabled, and the __test cookie exists in the browser.
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.
The security check doesn’t block same-domain AJAX. The article on it says JavaScript calls to your own website’s endpoints work fine, and it says cross-domain (CORS) requests are blocked.
So a fetch() that gets the aes.js page usually means the request isn’t treated as same-site. That could happen if the page runs on a different address than the endpoint, such as a different domain, a www and non-www mix, http against https, or a local file or dev server.
What exact URL is in your fetch() call, and what address is in the browser bar when you submit the form?
The registration page and PHP endpoint use the same HTTPS domain.
The database connection test succeeds.
Opening backend/register.php directly returns the expected JSON error for an invalid GET request.
Submitting the registration form with POST returns HTTP 200, but the response is the /aes.js anti-bot HTML instead of JSON.
I tested in Microsoft Edge and InPrivate mode, with the same result.
Could a human support staff member please investigate why this POST request is being intercepted by the security system? Is there a recommended workaround for PHP form submissions on free hosting?
For starters, HTTP POST requests, AJAX, form submissions and everything related to that should just work.
I just tested it, and I was able to complete the registration without issues. You may want to remove the registration for “example example” from your records.
I investigated a very similar issue for someone else yesterday, and I suspect it’s the same issue. Can you check what I wrote there and see if it also explains what’s happening for you?