summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Van Doorn <vandoorn.nick@gmail.com>2019-03-02 16:28:19 -0800
committerNick Van Doorn <vandoorn.nick@gmail.com>2019-03-02 16:28:19 -0800
commit8a01f0eda203c58fd171749cad3973551985ead7 (patch)
tree18d117efd2f4471e6e313083b356c178b7956deb
parent29aa733dfd4c94d23c5de8b92e0f95786700ebcf (diff)
Use cors
-rw-r--r--server/package.json6
-rw-r--r--server/src/operations.ts2
-rw-r--r--server/yarn.lock28
3 files changed, 32 insertions, 4 deletions
diff --git a/server/package.json b/server/package.json
index d6ae0f3..737eedb 100644
--- a/server/package.json
+++ b/server/package.json
@@ -14,10 +14,11 @@
"author": "Nicholas Van Doorn",
"license": "MIT",
"devDependencies": {
- "@types/jest": "^23.3.13",
- "@types/node": "^10.12.18",
"@types/body-parser": "^1.17.0",
"@types/express": "^4.16.0",
+ "@types/jest": "^23.3.13",
+ "@types/node": "^10.12.18",
+ "@types/cors": "^2.8.4",
"@types/ws": "^6.0.1",
"jest": "^23.6.0",
"ts-jest": "^23.10.5",
@@ -27,6 +28,7 @@
},
"dependencies": {
"body-parser": "^1.18.3",
+ "cors": "^2.8.5",
"express": "^4.16.4",
"ws": "^6.1.2"
}
diff --git a/server/src/operations.ts b/server/src/operations.ts
index a852a81..60932b3 100644
--- a/server/src/operations.ts
+++ b/server/src/operations.ts
@@ -8,6 +8,7 @@ import { decodePath } from '../../lib/path'
import { DatabaseInterface } from 'naive-core'
import express, { RequestHandler } from 'express'
+import cors from 'cors'
import bodyParser from 'body-parser'
export const bindOperations = (
@@ -62,6 +63,7 @@ export const bindOperations = (
const router = express()
router.use(bodyParser.json())
+ router.use(cors({ origin: true }))
router.get('/read/:path', readHandler)
router.post('/write', writeHandler)
router
diff --git a/server/yarn.lock b/server/yarn.lock
index 5d36ad8..bcf1fa2 100644
--- a/server/yarn.lock
+++ b/server/yarn.lock
@@ -33,6 +33,13 @@
dependencies:
"@types/node" "*"
+"@types/cors@^2.8.4":
+ version "2.8.4"
+ resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.4.tgz#50991a759a29c0b89492751008c6af7a7c8267b0"
+ integrity sha512-ipZjBVsm2tF/n8qFGOuGBkUij9X9ZswVi9G3bx/6dz7POpVa6gVHcj1wsX/LVEn9MMF41fxK/PnZPPoTD1UFPw==
+ dependencies:
+ "@types/express" "*"
+
"@types/events@*":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86"
@@ -47,6 +54,15 @@
"@types/node" "*"
"@types/range-parser" "*"
+"@types/express@*":
+ version "4.16.1"
+ resolved "https://registry.yarnpkg.com/@types/express/-/express-4.16.1.tgz#d756bd1a85c34d87eaf44c888bad27ba8a4b7cf0"
+ integrity sha512-V0clmJow23WeyblmACoxbHBu2JKlE5TiIme6Lem14FnPW9gsttyHtk6wq7njcdIWH1njAaFgR8gW09lgY98gQg==
+ dependencies:
+ "@types/body-parser" "*"
+ "@types/express-serve-static-core" "*"
+ "@types/serve-static" "*"
+
"@types/express@^4.16.0":
version "4.16.0"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.16.0.tgz#6d8bc42ccaa6f35cf29a2b7c3333cb47b5a32a19"
@@ -816,6 +832,14 @@ core-util-is@1.0.2, core-util-is@~1.0.0:
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
+cors@^2.8.5:
+ version "2.8.5"
+ resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
+ integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
+ dependencies:
+ object-assign "^4"
+ vary "^1"
+
cross-spawn@^5.0.1:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@@ -2825,7 +2849,7 @@ oauth-sign@~0.9.0:
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455"
integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==
-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"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
@@ -4024,7 +4048,7 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"
-vary@~1.1.2:
+vary@^1, vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=