Skip to content

Commit 98b4df7

Browse files
committed
fix server cors issue
1 parent afc08de commit 98b4df7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

plugin/com.dim.streamdeck.sdPlugin/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schemas.elgato.com/streamdeck/plugins/manifest.json",
33
"Name": "DIM Stream Deck",
4-
"Version": "3.3.3.0",
4+
"Version": "3.3.4.0",
55
"Author": "fcannizzaro",
66
"URL": "https://dimstreamdeck.vercel.app",
77
"PropertyInspectorPath": "pi/index.html",

plugin/src/main.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
1818
const server = http.createServer();
1919

2020
server.on("request", (req, res) => {
21+
res.setHeader("Access-Control-Allow-Origin", "*");
22+
res.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
23+
res.setHeader("Access-Control-Allow-Private-Network", "true");
24+
// Handle preflight requests
25+
if (req.method === "OPTIONS") {
26+
res.writeHead(204);
27+
res.end();
28+
return;
29+
}
2130
if (req.url === "/version") {
22-
res.writeHead(200, { "Access-Control-Allow-Origin": "*" });
2331
res.end(manifest.Version);
32+
} else {
33+
res.writeHead(404, { "Content-Type": "text/plain" });
34+
res.end("Not Found");
2435
}
2536
});
2637

0 commit comments

Comments
 (0)