From 23d769dda2ff6a8263a0667aa7e81c75ddd0607f Mon Sep 17 00:00:00 2001 From: Lisennk Date: Sat, 6 Jan 2018 16:02:36 +0200 Subject: [PATCH] fix Access-Control-Allow-Origin header to allow API usage from browsers --- src/Proxy.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Proxy.ts b/src/Proxy.ts index 4e4419d..e241ae5 100644 --- a/src/Proxy.ts +++ b/src/Proxy.ts @@ -120,8 +120,9 @@ class Proxy extends EventEmitter { if (url.pathname === "/version") { const body = JSON.stringify({ version }); res.writeHead(200, { + "Access-Control-Allow-Origin": "*", "Content-Length": Buffer.byteLength(body), - "Content-Type": "application/json" + "Content-Type": "application/json", }); res.end(body); return; @@ -153,6 +154,7 @@ class Proxy extends EventEmitter { } res.writeHead(200, { + "Access-Control-Allow-Origin": "*", "Content-Length": Buffer.byteLength(body), "Content-Type": "application/json" });