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

Fix: enable secure header middleware by default #1601

Merged
merged 6 commits into from
Sep 2, 2024
Merged
Changes from 2 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
7 changes: 2 additions & 5 deletions template/koa-rest-api/src/framework/server.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etaoins do you have any thoughts as Koala BDFL?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind this either. This is the big one because it can break loading all HTTP resources hosted on the same domain:

The app's domain does not mix HTTP and HTTPS

However, that's become even less common in the 5 years since this documentation was written. The other caveats only have a local effect and would presumably be caught during testing.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ErrorMiddleware,
MetricsMiddleware,
RequestLogging,
// SecureHeaders,
SecureHeaders,
VersionMiddleware,
} from 'seek-koala';

Expand Down Expand Up @@ -39,10 +39,7 @@ export const createApp = <State, Context>(
...middleware: Array<Koa.Middleware<State, Context>>
) =>
new Koa()
// TODO: consider using a middleware that adds secure HTTP headers.
// https://github.com/seek-oss/koala/tree/master/src/secureHeaders
// https://github.com/venables/koa-helmet
// .use(SecureHeaders.middleware)
.use(SecureHeaders.middleware)
tadhglewis marked this conversation as resolved.
Show resolved Hide resolved
.use(contextMiddleware)
.use(requestLogging)
.use(metrics)
Expand Down
Loading