From c5e8ae28713e46f797a60624a3151ad23e5b95bd Mon Sep 17 00:00:00 2001 From: Tracey Jaquith Date: Tue, 9 Apr 2024 00:07:45 +0000 Subject: [PATCH] .mem.gz files cant be application/javascript mime types. make nomad review app cluster use for testing easier --- Dockerfile | 4 +--- default.conf | 4 +++- loader.js | 14 ++++++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee97f6e..48280a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,7 @@ FROM nginx:alpine WORKDIR /usr/share/nginx/html -RUN rm -f index.html && \ - # xxx not great for files that dont end like: .js.gz .wasm.gz - sed -i 's/js;/js gz;/' /etc/nginx/mime.types +RUN rm -f index.html COPY default.conf /etc/nginx/conf.d/ diff --git a/default.conf b/default.conf index 728de58..45123c1 100644 --- a/default.conf +++ b/default.conf @@ -29,7 +29,7 @@ server { add_header Vary Origin; } - # customization - like above but with `Content-Encoding` header + # customization - like 1st location, but with `Content-Type` & `Content-Encoding` headers location ~\.(js|wasm)\.gz$ { root /usr/share/nginx/html; add_header Access-Control-Allow-Origin *; @@ -37,6 +37,8 @@ server { add_header Access-Control-Allow-Headers Accept-Encoding,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,DNT,Pragma,Range,X-Requested-With; add_header Vary Origin; + types { } + default_type application/javascript; add_header Content-Encoding gzip; } diff --git a/loader.js b/loader.js index 9ca56e2..9d14d6b 100644 --- a/loader.js +++ b/loader.js @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +/* eslint-disable */ var Module = null; (function (Promise) { @@ -710,8 +711,13 @@ var Module = null; // NOTE: deliberately use cors.archive.org since this will 302 rewrite to iaXXXXX.us.archive.org/XX/items/... // and need to keep that "artificial" extra domain-ish name to avoid CORS issues with IE/Safari (tracey@archive) var get_cors_url = function(item, path) { - if (item === 'emularity-engine' || item === 'emularity-config' || item === 'emularity-bios') - return '//' + item + '.ux-b.archive.org/' + (path ? '/' + path : ''); + if (item === 'emularity-engine' || item === 'emularity-config' || item === 'emularity-bios') { + // allow optional testing CGI arg to hit the review app test cluster + // (helpful for testing out pre-production code & files) + var prefix = location.search.indexOf('?devao=1') < 0 ? '' : 'internetarchive-'; + var domain = location.search.indexOf('?devao=1') < 0 ? 'ux-b.archive.org' : 'dev.archive.org'; + return '//' + prefix + item + '.' + domain + '/' + path; + } return '//cors.archive.org/cors/' + item + (path ? '/' + path : ''); } @@ -1927,11 +1933,11 @@ var Module = null; for (var i = 1; i < parts.length; i++) { var path = '/'+ parts.slice(0, i).join('/'); if (!deltaFS.existsSync(path)) { - deltaFS.mkdirSync(path, 0777); + deltaFS.mkdirSync(path, 0777); // 0o777 strict xxx } } } - deltaFS.writeFileSync(filename, new Buffer(data), null, flag_w, 0644); + deltaFS.writeFileSync(filename, new Buffer(data), null, flag_w, 0644); // 0o644 strict xxx } }; }