Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.

Commit 3f6be80

Browse files
committed
Local server is not accesible from outside
fixes #155
1 parent ff18817 commit 3f6be80

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

src/ios/CDVWKWebViewEngine.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ - (instancetype)initWithFrame:(CGRect)frame
6666
self.frame = frame;
6767
self.webServer = [[GCDWebServer alloc] init];
6868
[self.webServer addGETHandlerForBasePath:@"/" directoryPath:@"/" indexFilename:nil cacheAge:3600 allowRangeRequests:YES];
69-
[self.webServer startWithPort:8080 bonjourName:nil];
69+
NSDictionary *options = @{
70+
GCDWebServerOption_Port: @(8080),
71+
GCDWebServerOption_BindToLocalhost: @(YES),
72+
GCDWebServerOption_ServerName: @"Ionic"
73+
};
74+
[self.webServer startWithOptions:options error:nil];
7075
}
7176

7277
return self;

src/ios/GCDWebServer/Core/GCDWebServer.m

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,24 +1035,6 @@ - (GCDWebServerResponse*)_responseWithContentsOfDirectory:(NSString*)path {
10351035
NSMutableString* html = [NSMutableString string];
10361036
[html appendString:@"<!DOCTYPE html>\n"];
10371037
[html appendString:@"<html><head><meta charset=\"utf-8\"></head><body>\n"];
1038-
[html appendString:@"<ul>\n"];
1039-
for (NSString* file in enumerator) {
1040-
if (![file hasPrefix:@"."]) {
1041-
NSString* type = [[enumerator fileAttributes] objectForKey:NSFileType];
1042-
#pragma clang diagnostic push
1043-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1044-
NSString* escapedFile = [file stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
1045-
#pragma clang diagnostic pop
1046-
GWS_DCHECK(escapedFile);
1047-
if ([type isEqualToString:NSFileTypeRegular]) {
1048-
[html appendFormat:@"<li><a href=\"%@\">%@</a></li>\n", escapedFile, file];
1049-
} else if ([type isEqualToString:NSFileTypeDirectory]) {
1050-
[html appendFormat:@"<li><a href=\"%@/\">%@/</a></li>\n", escapedFile, file];
1051-
}
1052-
}
1053-
[enumerator skipDescendents];
1054-
}
1055-
[html appendString:@"</ul>\n"];
10561038
[html appendString:@"</body></html>\n"];
10571039
return [GCDWebServerDataResponse responseWithHTML:html];
10581040
}

0 commit comments

Comments
 (0)