Skip to content

Commit

Permalink
Merge pull request #4 from consenlabs/feature/cors
Browse files Browse the repository at this point in the history
解决跨域问题
  • Loading branch information
XuNeal authored Jun 22, 2020
2 parents beced83 + 03bac50 commit 1dfe0fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"dependencies": {
"@sentry/electron": "^1.3.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"electron-updater": "^4.3.1",
"element-ui": "^2.13.1",
"express": "^4.17.1",
Expand Down
3 changes: 3 additions & 0 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ function createTray () {
function startHttpServer () {
const express = require('express')
const app = express()
const cors = require('cors')
const bodyParser = require('body-parser')
const apiRouter = require('../api/apirouter')
// 配置cors解决跨域请求的问题
app.use(cors())
// 给app配置bodyParser中间件
// 通过如下配置再路由种处理request时,可以直接获得post请求的body部分
app.use(bodyParser.urlencoded({ extended: true }))
Expand Down
12 changes: 10 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3269,6 +3269,14 @@ [email protected], core-util-is@~1.0.0:
resolved "https://registry.npm.taobao.org/core-util-is/download/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=

cors@^2.8.5:
version "2.8.5"
resolved "https://registry.npm.taobao.org/cors/download/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
integrity sha1-6sEdpRWS3Ya58G9uesKTs9+HXSk=
dependencies:
object-assign "^4"
vary "^1"

crc32-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.npm.taobao.org/crc32-stream/download/crc32-stream-2.0.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcrc32-stream%2Fdownload%2Fcrc32-stream-2.0.0.tgz#e3cdd3b4df3168dd74e3de3fbbcb7b297fe908f4"
Expand Down Expand Up @@ -7830,7 +7838,7 @@ oauth-sign@~0.9.0:
resolved "https://registry.npm.taobao.org/oauth-sign/download/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455"
integrity sha1-R6ewFrqmi1+g7PPe4IqFxnmsZFU=

object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.npm.taobao.org/object-assign/download/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
Expand Down Expand Up @@ -10782,7 +10790,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.npm.taobao.org/vary/download/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
Expand Down

0 comments on commit 1dfe0fb

Please sign in to comment.