@rimelight/security 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimelight/security",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "private": false,
5
5
  "description": "Rimelight Entertainment Security Middleware and Utilities.",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "devDependencies": {
17
- "astro": "7.1.0",
17
+ "astro": "7.1.3",
18
18
  "typescript": "6.0.3"
19
19
  },
20
20
  "peerDependencies": {
@@ -79,8 +79,9 @@ function addSecurityHeaders(response: Response, origin?: string): Response {
79
79
  * Security Middleware: Injects SRI integrity attributes and security headers.
80
80
  */
81
81
  export const security = defineMiddleware(async (context, next) => {
82
- // HTTP to HTTPS redirect only in production
83
- if (import.meta.env.PROD && context.request.url.startsWith("http://")) {
82
+ // HTTP to HTTPS redirect only in production based on x-forwarded-proto
83
+ const proto = context.request.headers.get("x-forwarded-proto")
84
+ if (import.meta.env.PROD && proto === "http") {
84
85
  const httpsUrl = context.request.url.replace(/^http:/, "https:")
85
86
  return Response.redirect(httpsUrl, 301)
86
87
  }