去除cors()

This commit is contained in:
yulixing 2019-09-26 15:02:12 +08:00
parent 449fb6493a
commit cb3a740330
3 changed files with 7 additions and 16 deletions

View File

@ -10,7 +10,7 @@ const router = new Router()
const redisDao = new RedisDao() const redisDao = new RedisDao()
// 获取广告区域列表 // 获取广告区域列表
router.get('/', cors(), async (req, res, next) => { router.get('/', async (req, res, next) => {
try { try {
const query = req.query const query = req.query
const game_id = query.gameid const game_id = query.gameid

View File

@ -21,7 +21,7 @@ const corsOptions = {
} }
// 获取广告区域列表 // 获取广告区域列表
router.get('/list', cors(), async (req, res, next) => { router.get('/list', async (req, res, next) => {
try { try {
const games = await GameInfo.find({deleted: false}) const games = await GameInfo.find({deleted: false})
const result = [] const result = []

View File

@ -6,19 +6,10 @@ import GameJump from '../../models/admin/GameJump'
import cors from 'cors' import cors from 'cors'
const router = new Router() const router = new Router()
const whitelist = ['https://promotion.kingsome.cn', 'https://promotion-test.kingsome.cn', 'http://promotion.kingsome.cn','http://promotion-test.kingsome.cn']
const corsOptions = {
origin: function(origin, callback) {
if (whitelist.indexOf(origin) !== -1) {
callback(null, true)
} else {
callback(new Error('Not allowed by CORS'))
}
},
}
// 获取游戏跳转关联列表 // 获取游戏跳转关联列表
router.get('/', cors(corsOptions), async (req, res, next) => { router.get('/', async (req, res, next) => {
try { try {
const query = req.query const query = req.query
const currentPage = parseInt(query.currentPage) const currentPage = parseInt(query.currentPage)
@ -52,7 +43,7 @@ router.get('/', cors(corsOptions), async (req, res, next) => {
}) })
// 添加关联游戏 // 添加关联游戏
router.post('/', cors(corsOptions), async (req, res, next) => { router.post('/', async (req, res, next) => {
try { try {
const body = req.body const body = req.body
const game_id = body.game_id const game_id = body.game_id
@ -93,7 +84,7 @@ router.post('/', cors(corsOptions), async (req, res, next) => {
} }
}) })
// 修改关联游戏 // 修改关联游戏
router.put('/', cors(corsOptions), async (req, res, next) => { router.put('/', async (req, res, next) => {
try { try {
const body = req.body const body = req.body
const jump_id = body._id const jump_id = body._id
@ -126,7 +117,7 @@ router.put('/', cors(corsOptions), async (req, res, next) => {
}) })
// 删除关联游戏 // 删除关联游戏
router.delete('/', cors(corsOptions), async (req, res, next) => { router.delete('/', async (req, res, next) => {
try { try {
const body = req.body const body = req.body
const jump_id = body.jump_id const jump_id = body.jump_id