Skip to content
Source
Sign inSign up
pingdotgg/t3code

security: add HTTP security headers, CSP, and core dump gitignore #1782

Closedbscheffbuch(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/1782/headopened View on GitHub

Showing 3 changed files with 18 additions and 1 deletion.

x
0 of 3 viewed, 3 left
13 additions and 1 deletionapps/server/src/server.tsModified
View file
@@ -1,5 +1,5 @@
import { Effect, Layer } from "effect";
-import { FetchHttpClient, HttpRouter, HttpServer } from "effect/unstable/http";
+import { FetchHttpClient, HttpRouter, HttpServer, HttpServerResponse } from "effect/unstable/http";
​
import { ServerConfig } from "./config";
import {
@@ -216,6 +216,17 @@
websocketRpcRouteLayer,
​
+/** Middleware that appends standard security headers to every HTTP response. */
+const securityHeadersMiddleware = HttpRouter.middleware(
+ (httpApp) =>
+ Effect.map(httpApp, (response) =>
+ HttpServerResponse.setHeaders(response, {
+ "x-content-type-options": "nosniff",
+ "x-frame-options": "DENY",
+ }),
+ ),
+);
+​
export const makeServerLayer = Layer.unwrap(
Effect.gen(function* () {
const config = yield* ServerConfig;
@@ -234,6 +245,7 @@
HttpRouter.serve(makeRoutesLayer, {
disableLogger: !config.logWebSocketEvents,
}),