diff --git a/rift/package.json b/rift/package.json index de450dd..6eb1006 100644 --- a/rift/package.json +++ b/rift/package.json @@ -16,6 +16,7 @@ "license": "MIT", "devDependencies": { "@types/body-parser": "^1.16.3", + "@types/cors": "^2.8.1", "@types/express": "^4.0.35", "@types/node": "^7.0.29", "typescript": "^2.3.4" @@ -23,6 +24,7 @@ "dependencies": { "basie": "^1.1.0", "body-parser": "^1.17.2", + "cors": "^2.8.3", "express": "^4.15.3" } } diff --git a/rift/src/index.ts b/rift/src/index.ts index 141d21b..06f3533 100644 --- a/rift/src/index.ts +++ b/rift/src/index.ts @@ -1,6 +1,7 @@ import { Database } from "basie"; import { Instance } from "./database"; import express = require("express"); +import cors = require("cors"); import bodyParser = require("body-parser"); // Returns the external IP of the request, or null if it is missing or invalid @@ -20,6 +21,7 @@ function getExternalIP(req: express.Request): string | null { console.log("[*] Creating web front..."); const app = express(); app.use(bodyParser.json()); + app.use(cors()); app.put("/discovery", async (req, res) => { // Reject invalid payloads. @@ -63,4 +65,4 @@ function getExternalIP(req: express.Request): string | null { app.listen(8003); console.log("[+] Listening at 0.0.0.0:8003... ^C to exit."); -})(); \ No newline at end of file +})(); diff --git a/rift/yarn.lock b/rift/yarn.lock index bc60747..a4cec68 100644 --- a/rift/yarn.lock +++ b/rift/yarn.lock @@ -7,6 +7,12 @@ "@types/express" "*" "@types/node" "*" +"@types/cors": + version "2.8.1" + resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.1.tgz#54073caf3b7a741e67fb82483f83a6cadfba7501" + dependencies: + "@types/express" "*" + "@types/express", "@types/express@*": version "4.0.35" resolved "https://registry.yarnpkg.com/@types/express/-/express-4.0.35.tgz#6267c7b60a51fac473467b3c4a02cd1e441805fe" @@ -196,6 +202,13 @@ core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" +cors: + version "2.8.3" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.3.tgz#4cf78e1d23329a7496b2fc2225b77ca5bb5eb802" + dependencies: + object-assign "^4" + vary "^1" + cryptiles@2.x.x: version "2.0.5" resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" @@ -603,7 +616,7 @@ oauth-sign@~0.8.1: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" -object-assign@^4.1.0: +object-assign@^4, object-assign@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -913,7 +926,7 @@ uuid@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" -vary@~1.1.1: +vary@^1, vary@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.1.tgz#67535ebb694c1d52257457984665323f587e8d37"