const express = require('express');
const request = require('request');
const cookies = require('./cookie');

const app = express();

app.use('*', (req, res) => {
  res.header('Access-Control-Allow-Origin', 'http://localhost:3000');
  res.header('Access-Control-Allow-Credentials', 'true');
  console.log(new Date(), ' -- Request Received:', req.originalUrl);
  req.headers.cookie = cookies;
  /**
   * Credit to: https://blog.javascripting.com/2015/01/17/dont-hassle-with-cors/
   */
  const url = 'https://worker.mturk.com' + req.originalUrl;
  req.pipe(request(url)).pipe(res);
});

app.set('port', process.env.PORT || 7777);

const server = app.listen(app.get('port'), () => {
  console.log(`Express running → PORT ${server.address().port}`);
});

@@ -28,17 +28,16 @@
 press');
-%0D
 %0Aconst r
@@ -64,17 +64,16 @@
 quest');
-%0D
 %0Aconst c
@@ -101,19 +101,17 @@
 ookie');
-%0D%0A%0D
+%0A
 %0Aconst a
@@ -125,19 +125,17 @@
 press();
-%0D%0A%0D
+%0A
 %0Aapp.use
@@ -155,17 +155,16 @@
 es) =%3E %7B
-%0D
 %0A  res.h
@@ -225,17 +225,16 @@
 :3000');
-%0D
 %0A  res.h
@@ -283,17 +283,16 @@
 'true');
-%0D
 %0A  conso
@@ -298,16 +298,21 @@
 ole.log(
+%0A    
 new Date
@@ -313,17 +313,58 @@
 w Date()
-,
+.toLocaleTimeString(),%0A    req.method,%0A   
  ' -- Re
@@ -380,16 +380,20 @@
 eived:',
+%0A   
  req.ori
@@ -400,19 +400,21 @@
 ginalUrl
+%0A  
 );
-%0D
 %0A  req.h
@@ -441,16 +441,14 @@
 ies;
-%0D
 %0A  /**
-%0D
 %0A   
@@ -528,16 +528,14 @@
 ors/
-%0D
 %0A   */
-%0D
 %0A  c
@@ -590,17 +590,16 @@
 inalUrl;
-%0D
 %0A  req.p
@@ -630,16 +630,13 @@
 es);
-%0D
 %0A%7D);
-%0D%0A%0D
+%0A
 %0Aapp
@@ -678,11 +678,9 @@
 77);
-%0D%0A%0D
+%0A
 %0Acon
@@ -726,17 +726,16 @@
  () =%3E %7B
-%0D
 %0A  conso
@@ -796,11 +796,9 @@
 %7D%60);
-%0D
 %0A%7D);
-%0D
 %0A

Edit console message.