Skip to content
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
24 changes: 22 additions & 2 deletions app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
import path from "path"
import react from "@vitejs/plugin-react"
import tailwindcss from "@tailwindcss/vite"
import { defineConfig } from "vite"
import { defineConfig, type Plugin } from "vite"

// Tracker GoatCounter SOLO en el build de la demo pública (issue #112):
// VITE_GC_COUNT=https://stats.helios.cloudless.club npm run build
// Los builds normales NO lo llevan: una instalación self-hosted nunca debe
// llamar a casa. Los hits se registran con prefijo /demo en el mismo site
// que la landing ("/" = landing, "/demo/..." = demo).
const gcCount = process.env.VITE_GC_COUNT?.replace(/\/$/, "")

function goatcounterPlugin(): Plugin {
return {
name: "helios-goatcounter",
transformIndexHtml(html) {
if (!gcCount) return html
const snippet =
` <script>window.goatcounter={path:function(p){return '/demo'+p}}</script>\n` +
` <script async data-goatcounter="${gcCount}/count" src="${gcCount}/count.js"></script>\n </head>`
return html.replace("</head>", snippet)
},
}
}

// https://vite.dev/config/
export default defineConfig({
base: './',
plugins: [react(), tailwindcss()],
plugins: [react(), tailwindcss(), goatcounterPlugin()],
server: {
port: 3000,
},
Expand Down
5 changes: 4 additions & 1 deletion server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,16 @@ app.post('/api/update/apply', async (c) => {


// Security headers middleware
// GC_ORIGIN (solo demo pública, issue #112): origen extra permitido en CSP
// para el tracker GoatCounter. Las instalaciones normales no lo definen.
const gcOrigin = process.env.GC_ORIGIN ? ` ${process.env.GC_ORIGIN}` : ''
app.use('*', async (c, next) => {
c.header('X-Content-Type-Options', 'nosniff')
c.header('X-Frame-Options', 'DENY')
c.header('Referrer-Policy', 'strict-origin-when-cross-origin')
c.header('Permissions-Policy', 'geolocation=(), microphone=(), camera=()')
c.header('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')
c.header('Content-Security-Policy', "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; connect-src 'self' https://api.github.com")
c.header('Content-Security-Policy', `default-src 'self'; script-src 'self' 'unsafe-inline'${gcOrigin}; style-src 'self' 'unsafe-inline'; connect-src 'self' https://api.github.com${gcOrigin}`)
await next()
})
const sseClients = new Set()
Expand Down
Loading