优化 cors 设置

This commit is contained in:
binaryify 2017-08-17 11:09:38 +08:00
parent a91bae2e86
commit f71f586073
3 changed files with 275 additions and 81 deletions

14
app.js
View File

@ -7,12 +7,14 @@ let cache = apicache.middleware
// 跨域设置 // 跨域设置
// app.all('*', function (req, res, next) { // app.all('*', function (req, res, next) {
// res.header("Access-Control-Allow-Credentials", true) // if (req.path !== '/' && !req.path.includes('.')) {
// res.header("Access-Control-Allow-Origin", "*") // res.header('Access-Control-Allow-Credentials', true)
// res.header("Access-Control-Allow-Headers", "X-Requested-With") // // 这里获取 origin 请求头 而不是用 *
// res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS") // res.header('Access-Control-Allow-Origin', req.headers['origin'] || '*')
// res.header("X-Powered-By", ' 3.2.1') // res.header('Access-Control-Allow-Headers', 'X-Requested-With')
// res.header("Content-Type", "application/json;charset=utf-8") // res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
// res.header('Content-Type', 'application/json;charset=utf-8')
// }
// next() // next()
// }) // })

340
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "NeteaseCloudMusicApi", "name": "NeteaseCloudMusicApi",
"version": "2.6.3", "version": "2.6.5",
"description": "网易云音乐 NodeJS 版 API", "description": "网易云音乐 NodeJS 版 API",
"scripts": { "scripts": {
"start": "node app.js", "start": "node app.js",