【发布时间】:2019-10-21 20:01:51
【问题描述】:
使用 Tymon jwt 令牌进行身份验证。 Laravel 工作正常。
当为 Laravel vapor 使用上传到 S3 的代码时,我无法获取签名存储 URL 来使用我的 axios 默认值:
axios.defaults.headers.common["Authorization"] = 'Bearer ' + token;
文档中显示的存储方法:
Vapor.store(this.$refs.file.files[0], {
progress: progress => {
this.uploadProgress = Math.round(progress * 100);
}
}).then(response => {
...
它在 npm 包的 index.js 中调用:
async store(file, options = null) {
// want this to use my default header.
const response = await axios.post('/vapor/signed-storage-url', {
'bucket': options.bucket || '',
'content_type': options.contentType || file.type,
'expires': options.expires || ''
});
可能与 npm 模块不在正确范围内有关。
我已经覆盖了 vapor-core signed-storage-url 控制器以使用令牌,并且可以让它与 Postman 一起工作。 它正在调用 Vapor.store,它不会将令牌添加到 axios 调用中,而且我看不到传递标头的方法。
编辑:您无需注册 Vapor 即可使用这些软件包。
composer require laravel/vapor-core
和
npm install --save-dev laravel-vapor
【问题讨论】:
标签: laravel vue.js axios laravel-vapor