Skip to content

Commit

Permalink
refactor(website): throw out puppeteer and use the service instead
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Jan 1, 2019
1 parent c6f9048 commit 3aa051a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 85 deletions.
73 changes: 2 additions & 71 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
"react": "16.7.0-alpha.2",
"react-dom": "16.7.0-alpha.2",
"emotion": "9.2.12",
"petit-dom": "0.2.2",
"puppeteer": "1.11.0"
"petit-dom": "0.2.2"
},
"devDependencies": {
"@babel/core": "7.2.2",
Expand Down
25 changes: 15 additions & 10 deletions packages/overmind-website/backend/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path')
const express = require('express')
const puppeteer = require('puppeteer')
const https = require('https')
const app = express()
const fs = require('fs')
const api = require('./api')
Expand Down Expand Up @@ -113,15 +113,20 @@ const googleCrawlMiddleware = async function ssr(req, res, next) {
.indexOf('googlebot') >= 0 &&
!path.extname(url)
) {
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
})
const page = await browser.newPage()
await page.goto(url, { waitUntil: 'networkidle0' })
const html = await page.content()
await browser.close()

res.send(html)
res.send(
await new Promise((resolve) => {
https.get(
'https://pptraas.com/ssr?url=https://overmindjs.org' + req.path,
(res) => {
let html = ''
res.on('data', (chunk) => {
html += chunk
})
res.on('end', () => resolve(html))
}
)
})
)
} else {
next()
}
Expand Down
3 changes: 1 addition & 2 deletions packages/overmind-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
"npm": "^6.3.0",
"overmind-react": "next",
"page": "^1.8.6",
"prismjs": "^1.15.0",
"puppeteer": "^1.11.0"
"prismjs": "^1.15.0"
},
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.1.6",
Expand Down

0 comments on commit 3aa051a

Please sign in to comment.