server : en-tête CORS sur /files/ (réutilisation des téléchargements)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 changed file +1 −0
modified
server.mjs
+1 −0
@@ -75,6 +75,7 @@ function serveFile(req, res, file, stat) { | |||||
| 75 | "Accept-Ranges": "bytes", | 75 | "Accept-Ranges": "bytes", | ||
| 76 | }; | 76 | }; | ||
| 77 | if (isHtml) headers["Content-Security-Policy"] = "frame-ancestors 'self'"; | 77 | if (isHtml) headers["Content-Security-Policy"] = "frame-ancestors 'self'"; | ||
| 78 | + if (/\/files\//.test(file)) headers["Access-Control-Allow-Origin"] = "*"; // téléchargements réutilisables (ex. dépôt Moodle) | ||||
| 78 | const ae = String(req.headers["accept-encoding"] || ""); | 79 | const ae = String(req.headers["accept-encoding"] || ""); | ||
| 79 | const canGzip = COMPRESSIBLE.has(ext) && stat.size > 1024 && !req.headers.range; | 80 | const canGzip = COMPRESSIBLE.has(ext) && stat.size > 1024 && !req.headers.range; | ||
| 80 | if (canGzip && /\bbr\b/.test(ae)) { | 81 | if (canGzip && /\bbr\b/.test(ae)) { | ||
| 81 | 82 | ||||