Skip to content

Commit 4b4036d

Browse files
committed
Add CORS header to try module scripts
1 parent 4e65587 commit 4b4036d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bin/cm.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ async function build() {
120120
function startServer() {
121121
let serve = join(root, "demo")
122122
let moduleserver = new (require("esmoduleserve/moduleserver"))({root: serve, maxDepth: 2})
123-
let serveStatic = require("serve-static")(serve)
123+
let serveStatic = require("serve-static")(serve, {
124+
setHeaders(res, path) {
125+
if (/try\/mods\//.test(path)) res.setHeader("Access-Control-Allow-Origin", "*")
126+
}
127+
})
124128
require("http").createServer((req, resp) => {
125129
if (/^\/test\/?($|\?)/.test(req.url)) {
126130
let runTests = require("@codemirror/buildhelper/src/runtests")

0 commit comments

Comments
 (0)