From 577f88c39899fed636ae4f8204b3b8214f0de345 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Sun, 22 Nov 2020 16:17:48 +0100 Subject: [PATCH] fix CORS and CSP --- src/components/Main.vue | 1 + src/router.js | 2 ++ src/store.js | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/src/components/Main.vue b/src/components/Main.vue index b366fa3..0d41c27 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -159,6 +159,7 @@ export default { stationid = this.favorites[i][0] } } + axios.defaults.headers.requesttoken = requesttoken await axios .delete(generateUrl(`/apps/radio/api/favorites/${stationid}`)) .then(response => { diff --git a/src/router.js b/src/router.js index 958eb18..1b51d62 100644 --- a/src/router.js +++ b/src/router.js @@ -7,6 +7,7 @@ import Main from './components/Main' import store from './store.js' Vue.use(Router) +const requesttoken = axios.defaults.headers.requesttoken const router = new Router({ base: generateUrl('/apps/radio/'), @@ -52,6 +53,7 @@ router.beforeEach((to, from, next) => { store.dispatch('setMenuState', to.name) next() } else { + axios.defaults.headers.requesttoken = requesttoken axios .get(generateUrl('/apps/radio/settings/menuState')) .then(async response => { diff --git a/src/store.js b/src/store.js index 96e8d11..d57b1e8 100644 --- a/src/store.js +++ b/src/store.js @@ -5,6 +5,7 @@ import axios from '@nextcloud/axios' import { generateUrl } from '@nextcloud/router' Vue.use(Vuex) +const requesttoken = axios.defaults.headers.requesttoken export default new Vuex.Store({ state: { @@ -52,11 +53,13 @@ export default new Vuex.Store({ state.player.title = title }, setMenuState(state, menuState) { + axios.defaults.headers.requesttoken = requesttoken axios.post(generateUrl('/apps/radio/settings/menuState'), { menuState, }) }, getMenuState(state) { + axios.defaults.headers.requesttoken = requesttoken axios .get(generateUrl('/apps/radio/settings/menuState')) .then(async response => { @@ -67,11 +70,13 @@ export default new Vuex.Store({ }) }, setVolumeState(state, volumeState) { + axios.defaults.headers.requesttoken = requesttoken axios.post(generateUrl('/apps/radio/settings/volumeState'), { volumeState, }) }, getVolumeState(state) { + axios.defaults.headers.requesttoken = requesttoken axios .get(generateUrl('/apps/radio/settings/volumeState')) .then(async response => {