From 21ee605541e864df2cf9dcf82802a4166e34519f Mon Sep 17 00:00:00 2001 From: Martijn Walraven Date: Thu, 7 Jan 2016 14:36:49 +0100 Subject: [PATCH] Support query parameter to avoid downloading index page when a file does not exist When downloading files during a Cordova hot code push, we need to detect if a file is not available instead of inadvertently downloading the default index page. --- packages/webapp/webapp_server.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/webapp/webapp_server.js b/packages/webapp/webapp_server.js index 1e8b78d18d..29a9b28bff 100644 --- a/packages/webapp/webapp_server.js +++ b/packages/webapp/webapp_server.js @@ -685,6 +685,17 @@ var runWebAppServer = function () { return undefined; } + if (request.url.query && request.url.query['meteor_dont_serve_index']) { + // When downloading files during a Cordova hot code push, we need + // to detect if a file is not available instead of inadvertently + // downloading the default index page. + // So similar to the situation above, we serve an uncached 404. + headers['Cache-Control'] = 'no-cache'; + res.writeHead(404, headers); + res.end("404 Not Found"); + return undefined; + } + // /packages/asdfsad ... /__cordova/dafsdf.js var pathname = connect.utils.parseUrl(req).pathname; var archKey = pathname.split('/')[1];