Skip to content

Commit f160594

Browse files
authored
Enable set AIRGAP cookie to view Lunr search results (#18648)
* Enable set `lunr` cookie to view Lunr search results * Use AIRGAP instead of lunr for cookie name
1 parent 059aea2 commit f160594

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

includes/explorer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% include breadcrumbs %}
22

33
<div class="graphql-container">
4-
{% if process.env.AIRGAP %}
4+
{% if AIRGAP %}
55
<p>GraphQL explorer is not available on this environment.</p>
66
{% else %}
77
<iframe id="graphiql" class="graphql-explorer" scrolling="no" src="{{ graphql.explorerUrl }}" allowfullscreen>

layouts/graphql-explorer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h1 class="border-bottom-0">{{ page.title }}</h1>
2121

2222
<div class="mt-2">
2323
<div>
24-
{% if process.env.AIRGAP %}
24+
{% if AIRGAP %}
2525
<p>GraphQL explorer is not available on this environment.</p>
2626
{% else %}
2727
<iframe id="graphiql" class="graphql-explorer" scrolling="no" src="{{ graphql.explorerUrl }}">

layouts/product-landing.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h1 class="mb-3 font-mktg">
4444
{% if page.product_video and page.product_video != '' %}
4545
<div class="col-12 col-lg-6">
4646
<div class="position-relative" style="padding-bottom:56.25%;">
47-
{% unless process.env.AIRGAP %}
47+
{% unless AIRGAP %}
4848
<iframe
4949
title="{{ page.shortTitle }} Video"
5050
class="top-0 left-0 position-absolute box-shadow-large rounded-1 width-full height-full"

middleware/context.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ module.exports = async function contextualize (req, res, next) {
2929
featureFlags.forEach(featureFlagName => {
3030
req.context.process.env[featureFlagName] = process.env[featureFlagName]
3131
})
32-
if (process.env.AIRGAP) req.context.process.env.AIRGAP = true
3332

3433
// define each context property explicitly for code-search friendliness
3534
// e.g. searches for "req.context.page" will include results from this file
@@ -64,8 +63,9 @@ module.exports = async function contextualize (req, res, next) {
6463
nonEnterpriseDefaultVersion
6564
},
6665
// `|| undefined` won't show at all for production
67-
airgap: Boolean(process.env.AIRGAP) || undefined
66+
airgap: Boolean(process.env.AIRGAP || req.cookies.AIRGAP) || undefined
6867
})
68+
if (process.env.AIRGAP || req.cookies.AIRGAP) req.context.AIRGAP = true
6969

7070
return next()
7171
}

middleware/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ router.get('/', async function postSearch (req, res, next) {
2222
}
2323

2424
try {
25-
const results = process.env.AIRGAP
25+
const results = process.env.AIRGAP || req.cookies.AIRGAP
2626
? await loadLunrResults({ version, language, query: `${query} ${filters || ''}`, limit })
2727
: await loadAlgoliaResults({ version, language, query, filters, limit })
2828
return res.status(200).json(results)

0 commit comments

Comments
 (0)