2021-11-15小书匠上绑定cheveroto图床
2021-11-15小书匠上绑定cheveroto图床
一、小书匠关于自定义绑定图床
1. chevero的开cors设置
cheveroto在我的服务中使用apache服务,在.htaccess文件中加入以下配置
- Header add Access-Control-Allow-Origin: "http://markdown.xiaoshujiang.com"
2. 小书匠的自定义图床设置如下:
在小书匠客户端绑定的时候一直报错,去网页版查看f12里console的信息,原来是跨域cors问题
- const fd = new FormData();
- fd.append('source', new File([fileData], filename));
- $.ajax({
- type: 'POST',
- url: 'http://XXXX.com/api/1/upload/?key=***********',
- data: fd,
- processData: false,
- contentType: false
- }).done(function(data){
- try{
- data = JSON.parse(data);
- } catch(e){}
- if (data.status_code != 200) {
- callback('上传失败' + data.message);
- } else {
- callback(null, data.image.filename, data.image.url, data);
- }
- }).fail(function(res, status, message){
- callback('上传资源失败:' + message);
- });
3. cheveroto中的api key查找
去搭建的cheveroto管理员主页通过dashboard-settings-api中查找