Rene Fichtmueller 1d4be52c83 fix: only send HSTS header on HTTPS connections, not HTTP
The learning process was failing to communicate with the gateway because:
1. Gateway was sending 'Strict-Transport-Security' header on HTTP responses
2. Node.js fetch respects HSTS and upgrades subsequent requests to HTTPS
3. Gateway only has HTTP listener (localhost:3103), no HTTPS
4. Result: SSL 'packet length too long' error on second request attempt

Solution: Modified registerHSTSMiddleware to only send HSTS header when
the connection is already secure (HTTPS or x-forwarded-proto: https).
HTTP connections will not get the HSTS header, preventing the forced upgrade.
2026-04-26 19:01:41 +02:00

40 lines
1.2 KiB
JSON

{
"name": "@llm-gateway/gateway",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "tsx watch src/server.ts",
"build": "tsc && npm run build:copy-assets",
"build:copy-assets": "mkdir -p dist/db/migrations dist/config dist/public && cp -r src/db/migrations/*.sql dist/db/migrations/ 2>/dev/null || true && cp -r src/config/*.yaml dist/config/ 2>/dev/null || true && cp -r public/* dist/public/ 2>/dev/null || true",
"start": "node dist/server.js",
"test": "vitest"
},
"dependencies": {
"@fastify/cors": "^10.1.0",
"@fastify/helmet": "^12.0.1",
"@fastify/rate-limit": "^10.3.0",
"@fastify/static": "^8.3.0",
"@shieldx/core": "file:../../../../../shieldx",
"ajv": "^8.17.1",
"fastify": "^5.8.5",
"franc": "^6.2.0",
"js-yaml": "^4.1.0",
"opossum": "^8.1.3",
"pg": "^8.13.1",
"pg-boss": "^10.1.3",
"pino": "^9.5.0",
"prom-client": "^15.1.3",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.10.6",
"@types/opossum": "^8.1.9",
"@types/pg": "^8.11.10",
"pino-pretty": "^13.1.3",
"tsx": "^4.19.2",
"typescript": "^5.7.2",
"vitest": "^2.1.8"
}
}