I installed functions-framework
and run a server locally by following this document.
https://cloud.google.com/functions/docs/functions-framework
package.json
"scripts": {
"start": "functions-framework --target=helloWorld"
}
index.js
exports.helloWorld = (req, res) => {
res.send('Hello, World');
};
-
npm start
...
Serving function...
Function: helloWorld
URL: http://localhost:8080/
curl localhost:8080
# Output: Hello, World
It works fine, so I changed index.js
to use Puppeteer
.
index.js
const puppeteer = require('puppeteer');
exports.helloWorld = async (req, res) => {
const browser = await puppeteer.launch({headless: false, args: ['--no-sandbox']});
const page = await browser.newPage();
page.goto('https://www.google.co.jp');
}
When I use curl localhost:8080
, the Chronium browser opens just once. But when I enter localhost:8080
in browser's address bar, it opens twice.
Why the Chronium opens twice?
I checked the behavior by Chrome
, Firefox
and Opera
, so it seems not depend on browsers.