Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STCLI-248 prune STS headers from server responses in the proxy #358

Merged
merged 2 commits into from
Nov 14, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 3.3.0 IN PROGRESS

* Prune STS headers, permitting local non-SSL access via proxy. Refs STCLI-248.

## [3.2.0](https://github.com/folio-org/stripes-cli/tree/v3.2.0) (2024-10-09)
[Full Changelog](https://github.com/folio-org/stripes-cli/compare/v3.1.0...v3.2.0)

Expand Down
7 changes: 7 additions & 0 deletions lib/run-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { createProxyMiddleware } = require('http-proxy-middleware');

const app = express();

// [argv.okapi, argv.port, argv.proxyHost, argv.proxyPort]);
const OKAPI = process.argv[2];
const PORT = process.argv[3];
const PROXY_HOST = process.argv[4];
Expand All @@ -15,8 +16,14 @@ app.use(
changeOrigin: true,
on: {
proxyRes: (proxyRes) => {
// STCOM-247: overwrite any CORS headers in responses with those of
// the proxy, thus allowing access from any browser pointed at the proxy.
proxyRes.headers['Access-Control-Allow-Origin'] = `${PROXY_HOST}:${PORT}`;
proxyRes.headers['Access-Control-Allow-Credentials'] = 'true';

// STCOM-248: omit STS headers in responses, thus allowing non-ssl access,
// e.g. access via http://localhost:3000
delete proxyRes.headers['Strict-Transport-Security'];
},
},
}),
Expand Down
Loading