fix CORS and CSP

This commit is contained in:
Jonas Heinrich 2020-11-22 16:17:48 +01:00
parent 1b23c68948
commit 577f88c398
3 changed files with 8 additions and 0 deletions

View File

@ -159,6 +159,7 @@ export default {
stationid = this.favorites[i][0] stationid = this.favorites[i][0]
} }
} }
axios.defaults.headers.requesttoken = requesttoken
await axios await axios
.delete(generateUrl(`/apps/radio/api/favorites/${stationid}`)) .delete(generateUrl(`/apps/radio/api/favorites/${stationid}`))
.then(response => { .then(response => {

View File

@ -7,6 +7,7 @@ import Main from './components/Main'
import store from './store.js' import store from './store.js'
Vue.use(Router) Vue.use(Router)
const requesttoken = axios.defaults.headers.requesttoken
const router = new Router({ const router = new Router({
base: generateUrl('/apps/radio/'), base: generateUrl('/apps/radio/'),
@ -52,6 +53,7 @@ router.beforeEach((to, from, next) => {
store.dispatch('setMenuState', to.name) store.dispatch('setMenuState', to.name)
next() next()
} else { } else {
axios.defaults.headers.requesttoken = requesttoken
axios axios
.get(generateUrl('/apps/radio/settings/menuState')) .get(generateUrl('/apps/radio/settings/menuState'))
.then(async response => { .then(async response => {

View File

@ -5,6 +5,7 @@ import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router' import { generateUrl } from '@nextcloud/router'
Vue.use(Vuex) Vue.use(Vuex)
const requesttoken = axios.defaults.headers.requesttoken
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
@ -52,11 +53,13 @@ export default new Vuex.Store({
state.player.title = title state.player.title = title
}, },
setMenuState(state, menuState) { setMenuState(state, menuState) {
axios.defaults.headers.requesttoken = requesttoken
axios.post(generateUrl('/apps/radio/settings/menuState'), { axios.post(generateUrl('/apps/radio/settings/menuState'), {
menuState, menuState,
}) })
}, },
getMenuState(state) { getMenuState(state) {
axios.defaults.headers.requesttoken = requesttoken
axios axios
.get(generateUrl('/apps/radio/settings/menuState')) .get(generateUrl('/apps/radio/settings/menuState'))
.then(async response => { .then(async response => {
@ -67,11 +70,13 @@ export default new Vuex.Store({
}) })
}, },
setVolumeState(state, volumeState) { setVolumeState(state, volumeState) {
axios.defaults.headers.requesttoken = requesttoken
axios.post(generateUrl('/apps/radio/settings/volumeState'), { axios.post(generateUrl('/apps/radio/settings/volumeState'), {
volumeState, volumeState,
}) })
}, },
getVolumeState(state) { getVolumeState(state) {
axios.defaults.headers.requesttoken = requesttoken
axios axios
.get(generateUrl('/apps/radio/settings/volumeState')) .get(generateUrl('/apps/radio/settings/volumeState'))
.then(async response => { .then(async response => {