0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

convert-svg-to-pngをVercel上で動かした。

Last updated at Posted at 2020-07-11

convert-svg-to-pngがVercel上で動いてくれない。

先日、convert-svg-to-pngを用いてOGPに対応したWebアプリを作りました。
しかしいざVercel上にデプロイしてみると、Internal Errorを吐いてしまいました…

Puppeteerからchrome-aws-lambdaを起動するようにすればおk

どうやらVercelのServerless FunctionsはAWS Lambdaを使っているらしく、Puppeteerは標準でそれに対応していないようでした。
そのため、Lambdaに対応したChromeを入れてあげれば動くようになります。

chrome-aws-lambdaをインストール
yarn add chrome-aws-lambda
ソースへ適応
import chrome from 'chrome-aws-lambda'
import { convert } from 'convert-svg-to-png'

convert('ここにSVGがはいる', {
    {
        args: chrome.args,
        executablePath: await chrome.executablePath,
        headless: chrome.headless,
    }
})

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?