Skip to content

Commit

Permalink
test fjerning av cookie med log i dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kenglxn committed Oct 2, 2023
1 parent 176e72b commit 879fae0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import httpProxyMiddleware, {
import { createHttpTerminator } from 'http-terminator';
import Prometheus from 'prom-client';
import { createLogger, format, transports } from 'winston';
import cookieParser from 'cookie-parser';
import { tokenXMiddleware } from './tokenx.js';
import { readFileSync } from 'fs';
import require from './esm-require.js';
Expand Down Expand Up @@ -67,7 +66,10 @@ const log = new Proxy(

const cookieScraperPlugin = (proxyServer, options) => {
proxyServer.on('proxyReq', (proxyReq, req, res, options) => {
delete proxyReq.header['cookie'];
if (proxyReq.header['cookie']) {
log.info('removing cookie from proxyReq. size=', proxyReq.header['cookie'].size);
delete proxyReq.header['cookie'];
}
});
};
// copy with mods from http-proxy-middleware https://github.com/chimurai/http-proxy-middleware/blob/master/src/plugins/default/logger-plugin.ts
Expand Down Expand Up @@ -144,7 +146,6 @@ const main = async () => {
const app = express();
app.disable('x-powered-by');
app.set('views', BUILD_PATH);
app.use(cookieParser());

app.use('/*', (req, res, next) => {
res.setHeader('NAIS_APP_IMAGE', NAIS_APP_IMAGE);
Expand Down

0 comments on commit 879fae0

Please sign in to comment.