dimkir / nightmare-lambda-tutorial

Sample project and tutorial to run NightmareJS on AWS Lambda
75 stars 9 forks source link

Proxy usage? #4

Open Raidus opened 6 years ago

Raidus commented 6 years ago

Hi,

I was able to get running nightmare on lambda with the help of your tutorial.

However using a proxy-server does not work.

    const nightmare = Nightmare({
      switches: {
        'proxy-server': 'url:port', // set the proxy server here ...
      },
      show: false,
      electronPath: electronPath, // you MUST specify electron path which you receive from installation
    });

The script doesn't crash but it's not using the proxy.

Any ideas?

mmsanalytics commented 6 years ago

I'm not sure if this is applicable to your situation, but I used this guide, too, and I'm able to use a local Charles proxy with this proxy-server config:

switches : {
     'proxy-server'  : '127.0.0.1:8888' 
}, 
dimkir commented 6 years ago

Does everything work when you try running the script locally (on your dev machine)?

Raidus commented 6 years ago

Sorry guys! I've made a stupid mistake. At some point, I've changed something in my custom deployment script and forgot to change it back. I just deployed the code without the "switches parameter". The code works perfectly with proxies. Big thanks to @dimkir for this repo!

I was using the es6 syntax. Just in case someone is interested:

  "scripts": {
    "package":
      "npm run package-prepare && cd dist && zip -rq ../deployment-package.zip index.js lib node_modules -x '*electron/dist*'",
    "package-prepare": "npm run babel && cp -r node_modules dist ",
    "deploy": "./lambda-install-aws.sh",
    "update":
      "npm run package && aws lambda update-function-code --function-name getstocknight-lambda --zip-file fileb://./deployment-package.zip",
    "babel":
      "rm -rf dist deployment-package.zip && mkdir dist && babel --presets es2015 --plugins async-to-promises index.js --out-dir dist && babel lib --out-dir dist/lib"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-plugin-async-to-promises": "^1.0.5",
    "babel-preset-es2015": "^6.24.1"
  }
dimkir commented 6 years ago

@Raidus that's a great example. I also like the idea of of using npm run scripts to make workflow steps more obvious (as compared ti running .sh scripts)