When i try make a api call with @angular/http or @angular/common/http, with headers or not, i get the error “Http failure response for (unknown url): 0 Unknown Error”, this only occurs in the Captive Portal for Apple Systems… with Safari, Safari private mode, Captive Portal Android, Chrome, Opera, works normally.
My Api is a SlimApp Php and I already implemented CORS.
$app->options(‘/{routes:.+}’, function ($request, $response, $args) {
return $response;
});
$app->add(function ($req, $res, $next) {
$response = $next($req, $res);
return $response
->withHeader(‘Access-Control-Allow-Origin’, ‘*’)
->withHeader(‘Access-Control-Allow-Headers’, ‘X-Requested-With, Content-Type, Accept, Origin, Authorization’)
->withHeader(‘Access-Control-Allow-Methods’, ‘GET, POST, DELETE, PUT, OPTIONS’);
});
My app is inside a rb mikrotik. Thanks!
Last time I was dealing with a similar issue, the cause was that iOS Safari for some bizarre reason needed both the web server and the hotspot portal to originate from the same IP, and differ only by port (instead of, like I wanted it, for the web server to be in a subdomain of the hotspot). I didn’t used CORS, but apparently, iOS Safari is ALSO violating that part too.
First of all thank you! Can you tell me what you did to get it to work?
Like I said, I made both use the same IP, but different ports.
You can add a dst-nat rule in the firewall to forward traffic to f.e. the router’s TCP 8080 to the web server’s TCP 80. More specifically:
/ip firewall nat add action=dst-nat chain=dstnat dst-address-type=local protocol=tcp port=8080 to-addresses=192.168.88.254 to-ports=80
And also, I had to use IPs as the hotspot address, not a DNS name.
My scenario:
mikrotik hotspot router: 10.5.0.1
webserver: 52.67.yy.xx (hosted in aws)
step-by-step:
1 - Create a dns static record in DNS Server for webserver.mydomain.com → 52.67.yy.xx
2 - Create a dns static record in DNS Server for webserver.mydomain.com → 10.5.0.1
3 - Create a firewall rule as you told
/ip firewall nat add action=dst-nat chain=dstnat dst-address-type=local protocol=tcp port=8080 to-addresses=10.5.0.1 to-ports=80
That’s right?
The whole point of the NAT is so that you only need a DNS record for the hotspot router 10.5.0.1.
Remove your DNS record for 52.67.yy.xx and change your links to only point to either “webserver.mydomain.com” or “webserver.mydomain.com:8080”. In fact, if you want things to also work on older iOS devices, you may want to remove DNS names entirely, and just use “10.5.0.1” and " 10.5.0.1:8080" in your links.
@boen_robot, after so much trying and trying i understood how to do it and it worked!
Thank you so much!!!