跳转 跨域
This commit is contained in:
parent
5586d4297a
commit
449fb6493a
@ -6,8 +6,19 @@ 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(), async (req, res, next) => {
|
router.get('/', cors(corsOptions), async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const query = req.query
|
const query = req.query
|
||||||
const currentPage = parseInt(query.currentPage)
|
const currentPage = parseInt(query.currentPage)
|
||||||
@ -41,7 +52,7 @@ router.get('/', cors(), async (req, res, next) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 添加关联游戏
|
// 添加关联游戏
|
||||||
router.post('/', cors(), async (req, res, next) => {
|
router.post('/', cors(corsOptions), 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
|
||||||
@ -82,7 +93,7 @@ router.post('/', cors(), async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 修改关联游戏
|
// 修改关联游戏
|
||||||
router.put('/', cors(), async (req, res, next) => {
|
router.put('/', cors(corsOptions), async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const body = req.body
|
const body = req.body
|
||||||
const jump_id = body._id
|
const jump_id = body._id
|
||||||
@ -115,7 +126,7 @@ router.put('/', cors(), async (req, res, next) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 删除关联游戏
|
// 删除关联游戏
|
||||||
router.delete('/', cors(), async (req, res, next) => {
|
router.delete('/', cors(corsOptions), 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user