recycleactor commited on
Commit
05feccb
·
verified ·
1 Parent(s): 5361c18

Upload server.js

Browse files
Files changed (1) hide show
  1. server.js +19 -0
server.js CHANGED
@@ -151,8 +151,20 @@ function jsWrapper(serverBase, baseUrl, transpiledCode, needRegenerator) {
151
  '}catch(e){}' +
152
  'try{if(window.__es5CssVarsApply)window.__es5CssVarsApply();}catch(e){}' +
153
  'try{' +
 
 
 
 
 
 
 
 
 
154
  transpiledCode +
155
  '}catch(e){try{console.error("ES5 proxy plugin error",e&&e.message?e.message:e);}catch(e2){}}' +
 
 
 
156
  '__es5_active=false;' +
157
  'try{if(window.__es5CssVarsApply)window.__es5CssVarsApply();}catch(e){}' +
158
  '})();'
@@ -211,6 +223,13 @@ async function cssInline(url, depth, clientUA) {
211
  return css
212
  }
213
 
 
 
 
 
 
 
 
214
  app.get('/health', (req, res) => {
215
  res.status(200).json({ ok: true })
216
  })
 
151
  '}catch(e){}' +
152
  'try{if(window.__es5CssVarsApply)window.__es5CssVarsApply();}catch(e){}' +
153
  'try{' +
154
+ 'var __mock_script = document.createElement("script");' +
155
+ '__mock_script.src = __es5_base;' +
156
+ 'var __orig_cs_desc;' +
157
+ 'try {' +
158
+ '__orig_cs_desc = Object.getOwnPropertyDescriptor(Document.prototype, "currentScript") || Object.getOwnPropertyDescriptor(HTMLDocument.prototype, "currentScript") || Object.getOwnPropertyDescriptor(document, "currentScript");' +
159
+ 'if(!__orig_cs_desc) { document.currentScript = __mock_script; } else {' +
160
+ 'Object.defineProperty(document, "currentScript", { get: function(){ return __mock_script; }, configurable: true });' +
161
+ '}' +
162
+ '} catch(e_cs) {}' +
163
  transpiledCode +
164
  '}catch(e){try{console.error("ES5 proxy plugin error",e&&e.message?e.message:e);}catch(e2){}}' +
165
+ 'finally {' +
166
+ 'try { if(__orig_cs_desc) Object.defineProperty(document, "currentScript", __orig_cs_desc); else delete document.currentScript; } catch(e_cs2) {}' +
167
+ '}' +
168
  '__es5_active=false;' +
169
  'try{if(window.__es5CssVarsApply)window.__es5CssVarsApply();}catch(e){}' +
170
  '})();'
 
223
  return css
224
  }
225
 
226
+ app.use((req, res, next) => {
227
+ res.setHeader('Access-Control-Allow-Origin', '*');
228
+ res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
229
+ res.setHeader('Access-Control-Allow-Headers', '*');
230
+ next();
231
+ })
232
+
233
  app.get('/health', (req, res) => {
234
  res.status(200).json({ ok: true })
235
  })