NOTE
- curl では rails の public な URL に接続できる状態。
- rails の publiic directory に HTML file を設置して、headless chrome からアクセスしてPDF変換しようとしたとき。( http://localhost:3000/some.html )
- chrome では localhost が 127.0.0.1 に割り当てられておらず、localhost が使えない場合がありそうだが詳しくは未確認。 http://127.0.0.1:3000/ にアクセスさせると良いかも。
- 最初 node + puppeter を通して実行させていたが、 どうやら chrome 本体の処理で問題が起きていそうだった。
-
http://127.0.0.1:3000/some.html に接続しても動かず
Error: net::ERR_CONNECTION_REFUSED
が起こることがあった - docker container で hostname -i した結果のIPアドレスに対して chrome をアクセスすると動くケースがあった。 ( http://172.26.0.1:3000/some.html )
コマンド例
chromium-browser --headless --no-sandbox --disable-gpu --print-to-pdf http:/xxx/
google-chrome-stable --headless --no-sandbox --disable-gpu --print-to-pdf http:/xxx/
参考
ヘッドレス Chrome ことはじめ | Web | Google Developers
Original by Github issue
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。