Skip to content

Commit

Permalink
fix: force uploads to use auth headers instead of cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Jan 23, 2022
1 parent 92fe9d3 commit a04f7bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 13 additions & 1 deletion client/components/editor/editor-modal-media.vue
Expand Up @@ -143,7 +143,7 @@
allow-multiple='true'
:files='files'
max-files='10'
server='/u'
:server='filePondServerOpts'
:instant-upload='false'
:allow-revert='false'
@processfile='onFileProcessed'
Expand Down Expand Up @@ -230,6 +230,7 @@
<script>
import _ from 'lodash'
import { get, sync } from 'vuex-pathify'
import Cookies from 'js-cookie'
import vueFilePond from 'vue-filepond'
import 'filepond/dist/filepond.min.css'
Expand Down Expand Up @@ -312,6 +313,17 @@ export default {
},
currentAsset () {
return _.find(this.assets, ['id', this.currentFileId]) || {}
},
filePondServerOpts () {
const jwtToken = Cookies.get('jwt')
return {
process: {
url: '/u',
headers: {
'Authorization': `Bearer ${jwtToken}`
}
}
}
}
},
watch: {
Expand Down
4 changes: 4 additions & 0 deletions server/helpers/security.js
Expand Up @@ -31,6 +31,10 @@ module.exports = {
if (req && req.cookies) {
token = req.cookies['jwt']
}
// Force uploads to use Auth headers
if (req.path === '/u') {
return null
}
return token
}
])
Expand Down

0 comments on commit a04f7bd

Please sign in to comment.