The fact is that I have my own server with the HTTPS protocol and, despite this, data is not loaded from the server to mobile devices.
I will be very grateful if you try to connect using mobile devices
And if you manage to connect, write to me, thanks!
https://server.marandici.de/server.php
Well I’ve tried in Chrome on iPhone XR and says server ok!
With my mobile phone (Android 10) I logged into the site and the message “server ok” appears.
Thank you, game chat should work on mobile devices!
But unfortunately I haven’t solved this problem yet
Check the CORS in your server maybe in your .htaccess you can add some rules to allow request from any origin.
Some samples
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
I was a little ago wrapping my mind to allow this on mobile devices and that solve my problem
1 Like
<?php
header(“Access-Control-Allow-Origin: *”);
header(“Access-Control-Allow-Headers”, “origin, x-requested-with, content-type”);
header(“Access-Control-Allow-Methods”, “PUT, GET, POST, DELETE, OPTIONS”);
$hostname = ‘************’;
$username = ‘*********’;
$password = ‘*********’;
$database = ‘********’;
$link = mysqli_connect($hostname, $username, $password, $database)
or die("error " . mysqli_error($link));
$query = "SELECT * FROM users ORDER BY id DESC LIMIT 15";
$result = mysqli_query($link, $query) or die(“error” . mysqli_error($link));
while ($row = mysqli_fetch_array($result)) {
echo (" “.$row[‘message’] .” \n “.$row[‘date_time’] .”\n" ."\n" );
}
mysqli_close($link);
?>
Works on all devices !!!
kubak
April 11, 2021, 10:01pm
7
I tested the project with your URL on Android and it looks like a CORS problem. Add entries in .htaccess as provided by UlisesFreitas.
You can read what CORS is here:
Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources. CORS also relies on a mechanism by...
1 Like
This is important too in your PHP file above all add
header(“Access-Control-Allow-Origin: *”);
And this other line to match your server timezone
date_default_timezone_set(‘Europe/Madrid’);
1 Like
Problem solved thanks to everyone who participated!
Source code above!