Skip to content

Commit

Permalink
add security headers
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Mar 21, 2024
1 parent a5bc959 commit e43019d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,16 @@ public static void Main(string[] args)

if (appEnv.IsProduction)
{
app.UseHsts();
app.MapFallbackToFile("index.html", new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers.Append("Cache-Control", "no-store,no-cache");
ctx.Context.Response.Headers.Add("Content-Security-Policy", "default-src 'self' 'unsafe-inline'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' https://client.crisp.chat; script-src 'self' 'unsafe-inline' https://client.crisp.chat; font-src 'self' https://client.crisp.chat; connect-src wss://client.relay.crisp.chat https://client.crisp.chat;");
ctx.Context.Response.Headers.Add("X-Frame-Options", "DENY");
ctx.Context.Response.Headers.Add("X-Content-Type-Options", "nosniff");
ctx.Context.Response.Headers.Add("X-XSS-Protection", "1; mode=block");
ctx.Context.Response.Headers.Add("Cache-Control", "no-store,no-cache");
}
});

Expand Down
3 changes: 3 additions & 0 deletions src/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export default defineConfig({
},
server: {
port: 3000,
headers: {
"Content-Security-Policy": `default-src 'self' 'unsafe-inline'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' https://client.crisp.chat; script-src 'self' 'unsafe-inline' https://client.crisp.chat; font-src 'self' https://client.crisp.chat; connect-src wss://client.relay.crisp.chat https://client.crisp.chat ws://localhost:3000 http://localhost:3000`,
},
proxy: {
"/uploads": {
target: "http://localhost:5251",
Expand Down

0 comments on commit e43019d

Please sign in to comment.