New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #133 - nil reference to CDV_LOCAL_SERVER #135

merged 4 commits into from Aug 14, 2018
Jump to file or symbol
Failed to load files and symbols.
+12 −2
Diff settings


Just for now

Copy path View file
@@ -146,12 +146,13 @@ - (void)initWebServer
NSString * wwwPath = [[NSBundle mainBundle] pathForResource:@"www" ofType: nil];
[self updateBindPath];
[self setServerPath:wwwPath];
[self startServer];
NSDictionary * settings = self.commandDelegate.settings;
//bind to designated hostname or default to localhost
@@ -165,6 +166,14 @@ -(void)startServer
//set the local server name
self.CDV_LOCAL_SERVER = [NSString stringWithFormat:@"http://%@:%d", bind, portNumber];
NSDictionary * settings = self.commandDelegate.settings;
//bind to designated port or default to 8080
int portNumber = [settings cordovaFloatSettingForKey:@"WKPort" defaultValue:8080];
//enable suspend in background if set in config
BOOL suspendInBackground = [settings cordovaBoolSettingForKey:@"WKSuspendInBackground" defaultValue:YES];
@@ -755,7 +764,8 @@ -(void)setServerPath:(NSString *) path
if (restart) {
[self.webServer stop];
NSString *serverUrl = self.CDV_LOCAL_SERVER;
__block NSString* serverUrl = self.CDV_LOCAL_SERVER;
[self.webServer addGETHandlerForBasePath:@"/" directoryPath:path indexFilename:((CDVViewController *)self.viewController).startPage cacheAge:0 allowRangeRequests:YES];
[self.webServer addHandlerForMethod:@"GET" pathRegex:@"_file_/" requestClass:GCDWebServerFileRequest.class asyncProcessBlock:^(__kindof GCDWebServerRequest * _Nonnull request, GCDWebServerCompletionBlock _Nonnull completionBlock) {
NSString *urlToRemove = [serverUrl stringByAppendingString:@"/_file_"];
ProTip! Use n and p to navigate between commits in a pull request.