From 1aeb57fb57e485e49e16c5ee08548f22be8f02d4 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 18 Aug 2018 23:14:30 -0700 Subject: [PATCH] remove link rel=manifest for iOS (#443) fixes #45 in a better way than before --- inline-script.js | 6 ++++++ server.js | 11 ----------- templates/2xx.html | 8 +++++++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/inline-script.js b/inline-script.js index dffe370..f9a6a4d 100644 --- a/inline-script.js +++ b/inline-script.js @@ -34,3 +34,9 @@ if (!localStorage.store_currentInstance) { style.textContent = '.hidden-from-ssr { opacity: 1 !important; }' document.head.appendChild(style) } + +// TODO: remove this hack when Safari works with cross-origin window.open() +// in a PWA: https://github.com/nolanlawson/pinafore/issues/45 +if (/iP(?:hone|ad|od)/.test(navigator.userAgent)) { + document.head.removeChild(document.getElementById('theManifest')) +} diff --git a/server.js b/server.js index 7dd8c6c..e072ce1 100644 --- a/server.js +++ b/server.js @@ -48,17 +48,6 @@ app.use(nonDebugOnly(helmet({ } }))) -// TODO: remove this hack when Safari works with cross-origin window.open() -// in a PWA: https://github.com/nolanlawson/pinafore/issues/45 -app.get('/manifest.json', (req, res, next) => { - if (/iP(?:hone|ad|od)/.test(req.headers['user-agent'])) { - return res.status(404).send({ - error: 'manifest.json is disabled for iOS. see https://github.com/nolanlawson/pinafore/issues/45' - }) - } - return next() -}) - app.use(serveStatic('assets', { setHeaders: (res) => { res.setHeader('Cache-Control', 'public,max-age=600') diff --git a/templates/2xx.html b/templates/2xx.html index 0db83b2..1c7acae 100644 --- a/templates/2xx.html +++ b/templates/2xx.html @@ -6,7 +6,7 @@ - + @@ -77,6 +77,12 @@ if (!localStorage.store_currentInstance) { style.textContent = '.hidden-from-ssr { opacity: 1 !important; }' document.head.appendChild(style) } + +// TODO: remove this hack when Safari works with cross-origin window.open() +// in a PWA: https://github.com/nolanlawson/pinafore/issues/45 +if (/iP(?:hone|ad|od)/.test(navigator.userAgent)) { + document.head.removeChild(document.getElementById('theManifest')) +} })()