modify cors setting

This commit is contained in:
Jay 2019-08-06 14:50:54 +08:00
parent f328453df4
commit 21ca3831e7
4 changed files with 1614 additions and 15 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
node_modules

View File

@ -2,15 +2,15 @@
* Favicon Grabber * Favicon Grabber
*/ */
const express = require('express'); const express = require('express')
const cors = require('cors') const cors = require('cors')
const routers = { const routers = {
api: require('./api/router'), api: require('./api/router')
}; }
const server = express(); const server = express()
const NODE_PORT = parseInt(process.env.NODE_PORT, 10); const NODE_PORT = parseInt(process.env.NODE_PORT, 10)
server.get('/', (req, res) => { server.get('/', (req, res) => {
res.send('ok') res.send('ok')
@ -19,10 +19,11 @@ server.get('/', (req, res) => {
server.use(cors({ server.use(cors({
origin: (origin, cb) => { origin: (origin, cb) => {
cb(null, !!origin) cb(null, !!origin)
} },
credentials: true
})) }))
server.use('/api', routers.api); server.use('/api', routers.api)
server.listen(NODE_PORT, () => { server.listen(NODE_PORT, () => {
console.log(`Server listening on port ${NODE_PORT} in ${process.env.NODE_ENV} mode...`); console.log(`Server listening on port ${NODE_PORT} in ${process.env.NODE_ENV} mode...`)
}); })

1606
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,5 +24,8 @@
"markdown-it-prism": "^1.1.1", "markdown-it-prism": "^1.1.1",
"normalize-url": "^2.0.1", "normalize-url": "^2.0.1",
"request": "^2.81.0" "request": "^2.81.0"
},
"devDependencies": {
"standard": "^12.0.1"
} }
} }