GoogleChromeLabs / carlo

Web rendering surface for Node applications
Apache License 2.0
9.32k stars 309 forks source link

Pass options are environment variable #125

Open mlucool opened 5 years ago

mlucool commented 5 years ago

Hi,

Carlo is used by programs like ndb. It currently allows for chrome to be set via CHROME_PATH, but it does not allow for any way to pass other options to the launched chrome via environment variables. While all options may be a good idea, the one I care the most about is being able to pass args.

I am happy to implement this this feature by adding another environment variable CARLO_OPTIONS and doing a merge of the passed options and JSON.parse(process.env.CARLO_OPTIONS) here: https://github.com/GoogleChromeLabs/carlo/blob/master/lib/carlo.js#L589.

What do you think?

mlucool commented 5 years ago

@pavelfeldman any thoughts on this?

pavelfeldman commented 5 years ago

I don't think users should be able to pass arbitrary / raw flags to Chrome that is running the Carlo app. Carlo is just a framework and if the app wants to expose this capability, it can read the environment and pass corresponding arguments into Carlo. What kind of flags did you have in mind though? There might be some that would make sense to control on a generic Carlo framework level, I am just struggling coming up with a good example.

mlucool commented 5 years ago

For ndb to work in my setup, I need to not only pass the location of my chrome path, but also set a few flags in args: --disable-setuid-sandbox --no-sandbox --auth-server-whitelist='*.myurl.com'

I also tend to pass: ignoreHTTPSErrors: true for puppeteer in general, but this is unlikely needed here.

mlucool commented 5 years ago

@pavelfeldman Is this something you think should go into ndb?