mirror of
https://github.com/romancm/gamebrary
synced 2024-11-26 21:20:20 +00:00
Enabled cors
This commit is contained in:
parent
50ffb4ebed
commit
344771feb8
4 changed files with 5 additions and 5 deletions
|
@ -1,12 +1,13 @@
|
|||
const functions = require('firebase-functions');
|
||||
const axios = require('axios');
|
||||
const cors = require('cors')({origin: true});
|
||||
|
||||
axios.defaults.headers.common['user-key'] = functions.config().igdb.key;
|
||||
|
||||
const igdbUrl = 'https://api-endpoint.igdb.com';
|
||||
|
||||
exports.search = functions.https.onRequest((req, res) => {
|
||||
res.set('Access-Control-Allow-Origin', "*")
|
||||
|
||||
const { searchText, platformId } = req.query;
|
||||
|
||||
axios.get(`${igdbUrl}/games/?search=${searchText}&fields=*&filter[platforms][eq]=${platformId}&limit=20&order=popularity:desc`)
|
||||
|
@ -15,6 +16,8 @@ exports.search = functions.https.onRequest((req, res) => {
|
|||
});
|
||||
|
||||
exports.games = functions.https.onRequest((req, res) => {
|
||||
res.set('Access-Control-Allow-Origin', "*")
|
||||
|
||||
const { games, platformId } = req.query;
|
||||
|
||||
axios.get(`${igdbUrl}/games/${games}/?fields=id,name,slug,created_at,updated_at,summary,rating,category,player_perspectives,release_dates,name,cover,platforms,screenshots,videos,websites,esrb,pegi,themes.name,game.name&expand=game,themes,developers,publishers,game_engines,game_modes,genres,platforms,player_perspectives`)
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"cors": "^2.8.4",
|
||||
"express": "^4.16.4",
|
||||
"firebase-admin": "~6.0.0",
|
||||
"firebase-functions": "^2.0.3"
|
||||
},
|
||||
|
|
|
@ -851,7 +851,7 @@ expand-brackets@^2.1.4:
|
|||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
express@^4.16.2, express@^4.16.4:
|
||||
express@^4.16.2:
|
||||
version "4.16.4"
|
||||
resolved "https://registry.yarnpkg.com/express/-/express-4.16.4.tgz#fddef61926109e24c515ea97fd2f1bdbf62df12e"
|
||||
dependencies:
|
||||
|
|
|
@ -112,7 +112,6 @@ export default {
|
|||
return new Promise((resolve, reject) => {
|
||||
axios.get(`https://us-central1-gamebrary-8c736.cloudfunctions.net/search?searchText=${searchText}&platformId=130`)
|
||||
.then(({ data }) => {
|
||||
console.log(data);
|
||||
commit('SET_SEARCH_RESULTS', data);
|
||||
commit('CACHE_GAME_DATA', data);
|
||||
resolve();
|
||||
|
|
Loading…
Reference in a new issue