diff --git a/README.md b/README.md index 9055c587593..187d17675eb 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

Release version - Build status + Build status Downloads License diff --git a/bootstrap/update.go b/bootstrap/update.go index c688f0c2236..33ee07b736b 100644 --- a/bootstrap/update.go +++ b/bootstrap/update.go @@ -16,6 +16,7 @@ type GithubRelease struct { } func CheckUpdate() { + log.Infof("检查更新...") url:="https://api.github.com/repos/Xhofe/alist/releases/latest" resp,err:=http.Get(url) if err!=nil { diff --git a/conf.yml.example b/conf.yml.example index 339dfc4c191..424a82a9a85 100644 --- a/conf.yml.example +++ b/conf.yml.example @@ -1,17 +1,23 @@ info: title: AList #标题 - site_url: http://localhost:5277 #前端地址 - backend_url: http://localhost:5244 #后端地址 logo: "" #网站logo 如果填写,则会替换掉默认的 footer_text: Xhofe's Blog #网页底部文字 footer_url: https://www.nn.ci #网页底部文字链接 music_img: https://img.oez.cc/2020/12/19/0f8b57866bdb5.gif #预览音乐文件时的图片 check_update: true #前端是否显示更新 script: #自定义脚本,可以是脚本的链接,也可以直接是脚本内容,如document.querySelector('body').style="background-image:url('https://api.mtyqx.cn/api/random.php');background-attachment:fixed" + autoplay: true #视频是否自动播放 + preview: + url: https://view.alist.nn.ci/onlinePreview?url= #extensions中包含的后缀名预览的地址,默认使用了kkFileView,可以自行搭建 + pre_process: [base64,encodeURIComponent] #对地址的处理,支持base64,encodeURIComponent,encodeURI + extensions: [doc,docx,ppt,pptx,xls,xlsx,pdf] #使用上面的url预览的文件后缀 + text: [txt,htm,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,yml,go,sh,c,cpp,h,hpp] #要预览的文本文件的后缀,可以自行添加 + max_size: 5242880 server: port: "5244" #程序监听端口 search: true #是否开启搜索接口,开启搜索之后密码和根目录都会失效,所以前端暂时不做搜索 static: dist #前端文件目录 + site_url: '*' #建议直接填*,若有信任域名要求,可填写其他,逗号分割 cache: enable: true #是否开启缓存 expiration: 60 #缓存失效时间(单位:分钟) diff --git a/server/middlewares.go b/server/middlewares.go index e408a6b690c..c3399594a64 100644 --- a/server/middlewares.go +++ b/server/middlewares.go @@ -9,9 +9,15 @@ import ( func CrosHandler() gin.HandlerFunc { return func(context *gin.Context) { + origin:=context.GetHeader("Origin") + // 同源 + if origin == "" { + context.Next() + return + } method := context.Request.Method // 设置跨域 - context.Header("Access-Control-Allow-Origin",context.GetHeader("Origin")) + context.Header("Access-Control-Allow-Origin",origin) context.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE,UPDATE") context.Header("Access-Control-Allow-Headers", "Content-Length,session,Accept, Origin, Host, Connection, Accept-Encoding, Accept-Language, Keep-Alive, User-Agent, Cache-Control, Content-Type") context.Header("Access-Control-Expose-Headers", "Content-Length,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified")