美文网首页
fetch 调用阿里oss 服务器上传

fetch 调用阿里oss 服务器上传

作者: evilGenuis_9527 | 来源:发表于2018-12-26 14:26 被阅读0次

写代码的时候调用oss上传接口,提示

ERROR :Fetch API cannot load [http://localhost:8077/sonny/l...](http://localhost:8077/sonny/listUser?pageIndex=1&pageSize=10.) The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin '[http://localhost:8080](http://localhost:8080/)' is therefore not allowed access.

仔细一看,定位在了 credentials

  const defaultOptions = {
    credentials: 'include',
  };
  const newOptions = { ...defaultOptions, ...options };
  return fetch(url,newOptions).then()

携带cookie时,后台接口必须在响应头中添加

"Access-Control-Allow-Credentials","true"

但是由于oss上传不需要携带cookie。
所以在调用接口的地方配置一下

request(url,{credentials: 'omit',})

相关文章

  • fetch 调用阿里oss 服务器上传

    写代码的时候调用oss上传接口,提示 仔细一看,定位在了 credentials 携带cookie时,后台接口必须...

  • react oss上传进度条

    阿里云oss上传步骤 调用服务端接口uploadPost(),将相应参数传过去。 服务端拿到相应数据,调用oss服...

  • 文件上传的实现方式

    常见的文件上传方式 阿里云上传 阿里云直传oss(不经过中间服务器中转) 配置项options checkpoin...

  • 阿里云(I)

    参考资料:iOS 阿里云服务器图片上传iOS录制(或选择)视频,压缩、上传(整理)视频 拍摄 与压缩 阿里云OSS...

  • 基于springboot的文件上传

    文件上传方式 直接上传到应用服务器 上传到oss(阿里云,七牛云) 前端将图片转成Base64编码上传 上传服务器...

  • SpringBoot文件上传

    基于Spring Boot的文件上传上传方式:1.直接上传到应用服务器2.上传到OSS(内容存储服务器,如:阿里云...

  • 4 SpringBoot文件上传

    基于Spring Boot的文件上传上传方式:1.直接上传到应用服务器2.上传到OSS(内容存储服务器,如:阿里云...

  • 基于SpringBoot的文件上传

    方式: 直接上传到应用服务器 上传到OSS(阿里云、七牛云) 前端将图片转成Base64编码上传

  • 基于SpringBoot的文件上传

    文件上传方式:1.直接上传到应用服务器(速度,容量) 2.上传到oss(内容存储服务器)(阿里云,七牛云)3.前端...

  • 文件的上传

    基于SpringBoot的文件上传 上传方式: 1.直接上传到应用服务器 2.上传到OSS(阿里云、七牛云) 3....

网友评论

      本文标题:fetch 调用阿里oss 服务器上传

      本文链接:https://www.haomeiwen.com/subject/xlehlqtx.html