diff --git a/src/Manifest/ManifestLoader.php b/src/Manifest/ManifestLoader.php index 42c23c8..05cedca 100644 --- a/src/Manifest/ManifestLoader.php +++ b/src/Manifest/ManifestLoader.php @@ -29,14 +29,39 @@ public function __construct(BuildDirectoryProvider $directoryProvider, ManifestM public function loadManifest(string $fileName): array { $path = $this->getManifestPath($fileName); - $context = \stream_context_create(['ssl' => ['verify_peer' => false, 'verify_peer_name' => false]]); // webpack-dev-server uses self-signed certificate - $manifest = @\file_get_contents($path, false, $context); // @ - errors handled by custom exception + + if (\is_file($path)) { + $manifest = @\file_get_contents($path); // @ - errors handled by custom exception + } else { + $ch = \curl_init($path); + + if ($ch === false) { + $manifest = false; + } else { + \curl_setopt_array($ch, [ + \CURLOPT_RETURNTRANSFER => true, + \CURLOPT_FAILONERROR => true, + + // allow self-signed certificates + \CURLOPT_SSL_VERIFYHOST => 0, + \CURLOPT_SSL_VERIFYPEER => false, + ]); + /** @var string|false $manifest */ + $manifest = \curl_exec($ch); + + if ($manifest === false) { + $errorMessage = \curl_error($ch); + } + + \curl_close($ch); + } + } if ($manifest === false) { throw new CannotLoadManifestException(\sprintf( "Manifest file '%s' could not be loaded: %s", $path, - \error_get_last()['message'] ?? 'unknown error' + $errorMessage ?? (\error_get_last()['message'] ?? 'unknown error') )); }