Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

added in express middleware to handle session url issue #339

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:server:functional": "babel-tape-runner -r dotenv/config server/tests/**/*.func.js | node_modules/.bin/tap-spec",
"test:client": "mocha --require tools/testClientSetup.js tools/testSetup.js \"client/**/*.spec.js\"",
"test": "npm run test:client && npm run test:server",
"updateDB":"node_modules/.bin/sequelize db:migrate --env production"
"updateDB": "node_modules/.bin/sequelize db:migrate --env production"
},
"repository": {
"type": "git",
Expand All @@ -49,6 +49,7 @@
"connect-history-api-fallback": "^1.3.0",
"connect-redis": "^3.3.0",
"cookie-parser": "^1.4.3",
"cookie-session": "^1.3.3",
"csv": "^1.1.0",
"debug": "^2.6.8",
"dompurify": "^0.9.0",
Expand Down
15 changes: 9 additions & 6 deletions server/config/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path');
const express = require('express');
const passport = require('passport');
const helmet = require('helmet');

const cookieSession = require('cookie-session');
const configureSequelize = require('./sequelize');
const configureWebpackDevMiddleware = require('./webpack-dev-middleware');
const configureRedis = require('./redis');
Expand All @@ -23,11 +23,7 @@ module.exports = () => {
configureWebpackDevMiddleware(app);

// Configure redis, receiving connections to client, subscriber and publisher
const {
client,
subscriber,
publisher,
} = configureRedis();
const { client, subscriber, publisher } = configureRedis();

// Configure session handling with redis, through the client connection.
const { sessionMiddleware } = configureSession(client);
Expand All @@ -42,6 +38,13 @@ module.exports = () => {
app.use(passport.session()); // Use passport middleware for auth
app.use(helmet()); // Implements various security tweaks to http response headers

app.use(
cookieSession({
maxAge: 30 * 24 * 60 * 60 * 1000,
keys: [process.env.COOKIE_SESSION]
})
);

app.use('/public', express.static(path.join(__dirname, '../../../public'))); // Serve /public static files when unauth
app.use('/dist', express.static(path.join(__dirname, '../../../dist'))); // Serve /dist static diles when auth

Expand Down