Skip to content

Commit 2ee9c1c

Browse files
authored
Merge pull request #340 from developmentseed/enhance/add-maintenance-mode
Add maintenance mode to v1
2 parents 7f7fe95 + 7423ae8 commit 2ee9c1c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

app/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ app.use(boom())
3535
async function init () {
3636
await nextApp.prepare()
3737

38+
// On maintenance mode, render maintenance page
39+
if (process.env.MAINTENANCE_MODE === 'true') {
40+
app.get('/*', (req, res) => {
41+
return nextApp.render(req, res, '/maintenance')
42+
})
43+
return app
44+
}
45+
3846
/**
3947
* Sub apps init
4048
*/

pages/_app.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Layout from '../components/layout.js'
66
import PageBanner from '../components/banner'
77
import Button from '../components/button'
88
import { ToastContainer } from 'react-toastify'
9+
import MaintenancePage from './maintenance'
910

1011
class OSMHydra extends App {
1112
static async getInitialProps ({ Component, ctx }) {
@@ -26,10 +27,14 @@ class OSMHydra extends App {
2627
}
2728

2829
render () {
29-
const { Component, pageProps, userData } = this.props
30+
const { Component, pageProps, userData, router } = this.props
3031
let bannerContent
3132
let { uid, username, picture } = userData
3233

34+
if (router && router.pathname === '/maintenance') {
35+
return <MaintenancePage />
36+
}
37+
3338
// store the userdata in localstorage if in browser
3439
let authed
3540
if (typeof window !== 'undefined') {

pages/maintenance.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
export default function MaintenancePage () {
3+
return <div>OSM Teams is under maintenance, please come back soon.</div>
4+
}

0 commit comments

Comments
 (0)