Updated CORS
This commit is contained in:
parent
4c6f670297
commit
ddce225376
3 changed files with 12 additions and 9 deletions
11
app.js
11
app.js
|
@ -5,6 +5,7 @@ const cookieParser = require('cookie-parser')
|
||||||
const logger = require('morgan')
|
const logger = require('morgan')
|
||||||
const passport = require('passport')
|
const passport = require('passport')
|
||||||
const session = require('express-session')
|
const session = require('express-session')
|
||||||
|
const cors = require('cors')
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
|
@ -29,15 +30,7 @@ app.use(express.urlencoded({ extended: false }))
|
||||||
app.use(cookieParser())
|
app.use(cookieParser())
|
||||||
app.use(express.static(path.join(__dirname, 'public')))
|
app.use(express.static(path.join(__dirname, 'public')))
|
||||||
|
|
||||||
app.use('/',
|
app.use(cors())
|
||||||
function (req, res, next) {
|
|
||||||
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
||||||
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE')
|
|
||||||
res.setHeader('Access-Control-Allow-Credentials', true)
|
|
||||||
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization, cache-control, pragma, If-Modified-Since')
|
|
||||||
|
|
||||||
next()
|
|
||||||
})
|
|
||||||
|
|
||||||
app.use('/', require('./routes/vegetableTypes')(passport))
|
app.use('/', require('./routes/vegetableTypes')(passport))
|
||||||
app.use('/', require('./routes/vegetables')(passport))
|
app.use('/', require('./routes/vegetables')(passport))
|
||||||
|
|
9
package-lock.json
generated
9
package-lock.json
generated
|
@ -1288,6 +1288,15 @@
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||||
},
|
},
|
||||||
|
"cors": {
|
||||||
|
"version": "2.8.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz",
|
||||||
|
"integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=",
|
||||||
|
"requires": {
|
||||||
|
"object-assign": "^4",
|
||||||
|
"vary": "^1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"crc": {
|
"crc": {
|
||||||
"version": "3.4.4",
|
"version": "3.4.4",
|
||||||
"resolved": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz",
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"aws-sdk": "^2.311.0",
|
"aws-sdk": "^2.311.0",
|
||||||
"bcrypt-nodejs": "0.0.3",
|
"bcrypt-nodejs": "0.0.3",
|
||||||
"cookie-parser": "~1.4.3",
|
"cookie-parser": "~1.4.3",
|
||||||
|
"cors": "^2.8.4",
|
||||||
"debug": "~2.6.9",
|
"debug": "~2.6.9",
|
||||||
"express": "~4.16.0",
|
"express": "~4.16.0",
|
||||||
"express-session": "^1.15.6",
|
"express-session": "^1.15.6",
|
||||||
|
|
Loading…
Reference in a new issue