Skip to content

Commit

Permalink
✨ Add CORS to Rift
Browse files Browse the repository at this point in the history
  • Loading branch information
molenzwiebel committed Jun 10, 2017
1 parent 53eb21d commit 5c687a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions rift/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"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"
},
"dependencies": {
"basie": "^1.1.0",
"body-parser": "^1.17.2",
"cors": "^2.8.3",
"express": "^4.15.3"
}
}
4 changes: 3 additions & 1 deletion rift/src/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.");
})();
})();
17 changes: 15 additions & 2 deletions rift/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 5c687a7

Please sign in to comment.