Skip to content

Commit

Permalink
fix: Use shared init file to properly set nonce for async component l…
Browse files Browse the repository at this point in the history
…oading

Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl committed Aug 16, 2023
1 parent efc6a96 commit 543e197
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import Collectives from './Collectives.vue'
import router from './router.js'
import store from './store/store.js'
import { sync } from 'vuex-router-sync'
import { generateFilePath } from '@nextcloud/router'

/** Global directives */
import VTooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'

__webpack_public_path__ = generateFilePath('collectives', '', 'js/') // eslint-disable-line
import './shared-init.js'

// Register global directives
Vue.directive('Tooltip', VTooltip)
Expand Down
7 changes: 5 additions & 2 deletions src/shared-init.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { getRequestToken } from '@nextcloud/auth'
import { generateFilePath } from '@nextcloud/router'

// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken)
__webpack_nonce__ = btoa(getRequestToken())

if (!process.env.WEBPACK_SERVE) {
// eslint-disable-next-line
__webpack_public_path__ = OC.linkTo('collectives', 'js/')
__webpack_public_path__ = generateFilePath('collectives', '', 'js/')
} else {
// eslint-disable-next-line
__webpack_public_path__ = 'http://127.0.0.1:3000/'
Expand Down

0 comments on commit 543e197

Please sign in to comment.