Skip to content

Commit 3aa051a

Browse files
refactor(website): throw out puppeteer and use the service instead
1 parent c6f9048 commit 3aa051a

File tree

4 files changed

+19
-85
lines changed

4 files changed

+19
-85
lines changed

package-lock.json

Lines changed: 2 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
"react": "16.7.0-alpha.2",
4949
"react-dom": "16.7.0-alpha.2",
5050
"emotion": "9.2.12",
51-
"petit-dom": "0.2.2",
52-
"puppeteer": "1.11.0"
51+
"petit-dom": "0.2.2"
5352
},
5453
"devDependencies": {
5554
"@babel/core": "7.2.2",

packages/overmind-website/backend/index.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path')
22
const express = require('express')
3-
const puppeteer = require('puppeteer')
3+
const https = require('https')
44
const app = express()
55
const fs = require('fs')
66
const api = require('./api')
@@ -113,15 +113,20 @@ const googleCrawlMiddleware = async function ssr(req, res, next) {
113113
.indexOf('googlebot') >= 0 &&
114114
!path.extname(url)
115115
) {
116-
const browser = await puppeteer.launch({
117-
args: ['--no-sandbox', '--disable-setuid-sandbox'],
118-
})
119-
const page = await browser.newPage()
120-
await page.goto(url, { waitUntil: 'networkidle0' })
121-
const html = await page.content()
122-
await browser.close()
123-
124-
res.send(html)
116+
res.send(
117+
await new Promise((resolve) => {
118+
https.get(
119+
'https://pptraas.com/ssr?url=https://overmindjs.org' + req.path,
120+
(res) => {
121+
let html = ''
122+
res.on('data', (chunk) => {
123+
html += chunk
124+
})
125+
res.on('end', () => resolve(html))
126+
}
127+
)
128+
})
129+
)
125130
} else {
126131
next()
127132
}

packages/overmind-website/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
"npm": "^6.3.0",
4343
"overmind-react": "next",
4444
"page": "^1.8.6",
45-
"prismjs": "^1.15.0",
46-
"puppeteer": "^1.11.0"
45+
"prismjs": "^1.15.0"
4746
},
4847
"devDependencies": {
4948
"@babel/plugin-transform-react-jsx": "^7.1.6",

0 commit comments

Comments
 (0)