Added cors to functions / Replaced search endpoint with firebase cloud function

This commit is contained in:
Roman Cervantes 2018-10-18 22:55:06 -07:00
parent c186e3fda6
commit 50ffb4ebed
4 changed files with 5 additions and 9 deletions

View file

@ -1,6 +1,6 @@
const functions = require('firebase-functions');
const axios = require('axios');
const circular = require('circular-json');
const cors = require('cors')({origin: true});
axios.defaults.headers.common['user-key'] = functions.config().igdb.key;

View file

@ -10,7 +10,7 @@
},
"dependencies": {
"axios": "^0.18.0",
"circular-json": "^0.5.7",
"cors": "^2.8.4",
"express": "^4.16.4",
"firebase-admin": "~6.0.0",
"firebase-functions": "^2.0.3"

View file

@ -538,10 +538,6 @@ chownr@^1.0.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494"
circular-json@^0.5.7:
version "0.5.7"
resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.5.7.tgz#b8be478d72ea58c7eeda26bf1cf1fba43d188842"
class-utils@^0.3.5:
version "0.3.6"
resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"

View file

@ -108,11 +108,11 @@ export default {
});
},
SEARCH({ commit, state: { token } }, searchText) {
SEARCH({ commit }, searchText) {
return new Promise((resolve, reject) => {
const options = { headers: { token } };
axios.get(`${API_URL}/search?searchText=${searchText}&order=popularity:desc`, options)
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();