I have a simple NodeJS server set up, serving basic static files (slide show basically), so an index.html
with some *.js
files included via <script...>
and yadda yadda, that's a bit beside the point I think. I check the server host's IP as part of server start, and it is, for example, 192.168.1.10
with my server running on port 8080. When I visit http://192.168.1.10:8080/index.html
from a laptop, it works exactly as expected. When I visit from my iPhone, I get NSURLErrorDomain
with no other helpful information. The server itself logs all HTTP requests (successful or otherwise), and logs correctly for requests from laptops, but logs no request attempts at all when trying from iOS. I tried using port 80 to be more standard, but this results in the same error. How can I make it so that my stock basic out-of-the-box iPhone can visit a basic NodeJS server running nothing more complex than createServer(...
with require('http')
?
Asked
Active
Viewed 443 times
0

Steverino
- 2,099
- 6
- 26
- 50
1 Answers
0
First, there should be a error code alongside with the NSURLErrorDomain
; you can then check NSURLErrorDomain error codes description
for more information.
I would guess it has something to do with transport security.
You should either try to use the HTTPS secure protocol, or allow arbitrary loads by editing the Info.plist
file:
Information Property List -> App Transport Security Settings -> Allow Arbitrary Loads = YES
or, if you prefer xml:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
</dict>

Andreas Oetjen
- 9,889
- 1
- 24
- 34