Skip to content

Commit

Permalink
fix(website): correctly set crawler url target
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Jan 1, 2019
1 parent bc270d6 commit ff71fdc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/overmind-website/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,21 @@ const apis = getApis()
const searchData = getSearchData()

const googleCrawlMiddleware = async function ssr(req, res, next) {
const url = req.protocol + '://' + req.hostname + req.path

if (
req
.get('user-agent')
.toLowerCase()
.indexOf('googlebot') >= 0
.indexOf('googlebot') >= 0 &&
!path.extname(url)
) {
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox'],
})
const page = await browser.newPage()
await page.goto(req.hostname + req.path, { waitUntil: 'networkidle0' })
await page.goto(url, { waitUntil: 'networkidle0' })
const html = await page.content()
await browser.close()

Expand Down

0 comments on commit ff71fdc

Please sign in to comment.