Skip to content

Commit

Permalink
feat: add errorMessage to screenshot api
Browse files Browse the repository at this point in the history
  • Loading branch information
junseublim committed Dec 18, 2024
1 parent 799e62b commit 1bab145
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 66 deletions.
3 changes: 3 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const nextConfig = {
}
],
},
experimental: {
serverComponentsExternalPackages: ['puppeteer-core'],
},
webpack: (config) => {
config.resolve.alias['@'] = path.resolve(__dirname, 'src')
config.resolve.alias['public'] = path.resolve(__dirname, 'public')
Expand Down
68 changes: 9 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"next": "14.2.4",
"next-auth": "^5.0.0-beta.20",
"prettier-plugin-tailwindcss": "^0.6.5",
"puppeteer": "^23.10.4",
"puppeteer-core": "^23.11.0",
"react": "^18",
"react-device-detect": "^2.2.3",
"react-dom": "^18",
Expand Down
8 changes: 2 additions & 6 deletions src/app/board/api/screenshot/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextResponse } from 'next/server'
import puppeteer from 'puppeteer'
import puppeteer from 'puppeteer-core'

export async function POST(request: Request) {
const { boardId, polaroids }: { boardId: string; polaroids: string[] } =
Expand Down Expand Up @@ -33,11 +33,7 @@ export async function POST(request: Request) {
})
} catch (error) {
await browser.close()
const errorObj = error as Error

return new NextResponse(`Error taking screenshot: ${errorObj.message}`, {
status: 500,
statusText: errorObj.message,
})
return new NextResponse('Error taking screenshot', { status: 500 })
}
}

0 comments on commit 1bab145

Please sign in to comment.