|
1 | 1 | import express from 'express' |
| 2 | +import basicAuth from 'express-basic-auth' |
2 | 3 | import instrument from '../lib/instrument-middleware.js' |
3 | 4 | import haltOnDroppedConnection from './halt-on-dropped-connection.js' |
4 | 5 | import abort from './abort.js' |
@@ -61,6 +62,7 @@ import renderPage from './render-page.js' |
61 | 62 | const { NODE_ENV } = process.env |
62 | 63 | const isDevelopment = NODE_ENV === 'development' |
63 | 64 | const isTest = NODE_ENV === 'test' || process.env.GITHUB_ACTIONS === 'true' |
| 65 | +const isProduction = NODE_ENV === 'production' && process.env.HEROKU_PRODUCTION_APP |
64 | 66 |
|
65 | 67 | // Catch unhandled promise rejections and passing them to Express's error handler |
66 | 68 | // https://medium.com/@Abazhenov/using-async-await-in-express-with-node-8-b8af872c0016 |
@@ -143,16 +145,18 @@ export default function (app) { |
143 | 145 | instrument(archivedEnterpriseVersionsAssets, './archived-enterprise-versions-assets') |
144 | 146 | ) |
145 | 147 | ) |
146 | | - app.use( |
147 | | - '/storybook', |
| 148 | + app.use('/storybook', [ |
| 149 | + (isProduction && |
| 150 | + basicAuth({ users: { octocat: process.env.STORYBOOK_PASSWORD }, challenge: true })) || |
| 151 | + ((req, res, next) => next()), |
148 | 152 | express.static('storybook', { |
149 | 153 | index: false, |
150 | 154 | etag: false, |
151 | 155 | immutable: true, |
152 | 156 | lastModified: false, |
153 | 157 | maxAge: '1 day', // Relatively short in case we update index.html |
154 | | - }) |
155 | | - ) |
| 158 | + }), |
| 159 | + ]) |
156 | 160 | app.use( |
157 | 161 | '/assets', |
158 | 162 | express.static('assets', { |
|
0 commit comments