Skip to main content

How to Test Screenshot Locally

  • Clone repo https://github.com/powrful/screenshot
  • Run npm install
  • Run npm run dev
  • Replace this variables: process.env.BUCKET_NAME => www.powrcdn.com process.env.AWS_KEY => AWS_ACCESS_KEY_ID (check in config/application.yml) process.env.AWS_SECRET => AWS_SECRET_ACCESS_KEY (check in config/application.yml)
  • I couldn't make this file api/screenshot.js work locally. So I placed it here pages/api/screenshot.js instead, to test.
  • You may want to set headless:false in order to see the chromium browser opening up.
  • You may want to comment this line to test await browser.close(), so chromium stays open after finish taking the screenshot.

In Powr project

  • The screenshot endpoint is stored in $ENV[:APP_SCREENSHOT_ENDPOINT]. So if using docker, to test locally, replace that with http://host.docker.internal:3003/api/screenshot. The port 3003 depends on what comes up in the terminal once you run npm run dev.
  • File responsible for screenshots in powr project: app/workers/apps/plugin_screenshot_worker.rb
  • Example of url to test screenshot: http://localhost:3003/api/screenshot?url=https://localhost:3000/plugins/media-gallery/view?id=33366382&screenshot=true