Skip to content

Commit 6bdbe20

Browse files
authored
Default sponsors+discussions pages to nextjs rendering (github#19667)
* default to nextjs rendering on sponsors and discussions pages
1 parent f8f72fc commit 6bdbe20

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

feature-flags.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"FEATURE_TEST_TRUE": true,
33
"FEATURE_TEST_FALSE": false,
4-
"FEATURE_NEXTJS": false
4+
"FEATURE_NEXTJS": true
55
}

middleware/render-page.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ const { isConnectionDropped } = require('./halt-on-dropped-connection')
1010
const { nextHandleRequest } = require('./next')
1111

1212
const { HEROKU_RELEASE_VERSION, FEATURE_NEXTJS } = process.env
13+
14+
const defaultNextJSRoutes = FEATURE_NEXTJS
15+
? [
16+
'/en/sponsors',
17+
'/en/discussions'
18+
]
19+
: []
1320
const pageCacheDatabaseNumber = 1
1421
const pageCacheExpiration = 24 * 60 * 60 * 1000 // 24 hours
1522

@@ -88,7 +95,7 @@ module.exports = async function renderPage (req, res, next) {
8895
const isRequestingJsonForDebugging = 'json' in req.query && process.env.NODE_ENV !== 'production'
8996

9097
// Should the current path be rendered by NextJS?
91-
const renderWithNextjs = 'nextjs' in req.query && FEATURE_NEXTJS
98+
const renderWithNextjs = (defaultNextJSRoutes.includes(pathname) || 'nextjs' in req.query) && FEATURE_NEXTJS
9299

93100
// Is in an airgapped session?
94101
const isAirgapped = Boolean(req.cookies.AIRGAP)

tests/browser/browser.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,13 @@ describe('nextjs query param', () => {
314314

315315
it('conditionally renders through nextjs pipeline depending on FEATURE_NEXTJS value', async () => {
316316
const flagVal = require('../../feature-flags.json').FEATURE_NEXTJS
317-
await page.goto('http://localhost:4001/en/sponsors?nextjs=')
317+
await page.goto('http://localhost:4001/en/actions?nextjs=')
318318
const nextWrapper = await page.$('#__next')
319319
flagVal === true ? expect(nextWrapper).toBeDefined() : expect(nextWrapper).toBeNull()
320320
})
321321

322322
it('does not render through nextjs pipeline when nextjs query param is missing', async () => {
323-
await page.goto('http://localhost:4001/en/sponsors')
323+
await page.goto('http://localhost:4001/en/actions')
324324
const nextWrapper = await page.$('#__next')
325325
expect(nextWrapper).toBeNull()
326326
})

0 commit comments

Comments
 (0)