diff --git a/.env.template b/.env.template index ded7b9c2bb..b75f4c5b55 100644 --- a/.env.template +++ b/.env.template @@ -40,6 +40,9 @@ REDIS_URL=redis://:localpwd@localhost:6379 TRACKER_WEBSITE_ID= CRISP_WEBSITE_ID= +# Next +NEXT_APP_ACTIVATED=true + # NextAuth NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=fake-secret diff --git a/src/routes.ts b/src/routes.ts index f3331498f7..e39e05ce70 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -34,7 +34,7 @@ class routes { static ABONNEMENT_LETTRE_INFORMATION = '/abonnement-lettre-information.html'; static POST_SINSCRIRE_LETTRE_INFORMATION = '/s-inscrire-a-la-lettre-d-information'; static DECLARATION_ACCESSIBILITE = '/accessibilite.html'; - static LOGOUT_ACTION = '/auth/signOut'; + static LOGOUT_ACTION = process.env.NEXT_APP_ACTIVATED === 'true' ? '/auth/signOut' : '/logout'; static SIGNUP = '/signup.html'; static POST_SIGNUP = '/signup'; diff --git a/src/server.ts b/src/server.ts index beb3f0441e..3f8c0f12bf 100644 --- a/src/server.ts +++ b/src/server.ts @@ -171,22 +171,25 @@ export async function makeServer(port: number, sessionSecret: string) { }); /////// Custom server next - const nextApp = next({ - dev: false, - dir: join(__dirname, isLocalEnv ? '../' : '../..', 'packages', 'applications', 'ssr'), - }); + if (process.env.NEXT_APP_ACTIVATED === 'true') { + const nextApp = next({ + dev: false, + dir: join(__dirname, isLocalEnv ? '../' : '../..', 'packages', 'applications', 'ssr'), + }); - const nextHandler = nextApp.getRequestHandler(); + const nextHandler = nextApp.getRequestHandler(); - app.get('*', (req, res) => { - return nextHandler(req, res); - }); + app.get('*', (req, res) => { + return nextHandler(req, res); + }); - app.post('*', (req, res) => { - return nextHandler(req, res); - }); + app.post('*', (req, res) => { + return nextHandler(req, res); + }); + + await nextApp.prepare(); + } - await nextApp.prepare(); await bootstrap(); app.listen(port, () => { process.env.start_datetime = new Date().getTime().toString();