Skip to content

Commit

Permalink
☁️ origin
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jan 12, 2021
1 parent 8582918 commit 434eb25
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</p>
<p align="center">
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/release/Xhofe/alist" alt="Release version"></a>
<a href="https://github.com/Xhofe/alist/actions?query=workflow%3ABuild"><img src="https://github.com/Xhofe/alist/workflows/Build/badge.svg" alt="Build status"></a>
<a href="https://github.com/Xhofe/alist/actions?query=workflow%3ABuild"><img src="https://github.com/Xhofe/alist/workflows/build/badge.svg" alt="Build status"></a>
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/downloads/Xhofe/alist/latest/total" alt="Downloads"></a>
<a href="https://github.com/Xhofe/alist/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Xhofe/alist" alt="License"></a>
<a href="https://pay.xhofe.top">
Expand Down
1 change: 1 addition & 0 deletions bootstrap/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 8 additions & 2 deletions conf.yml.example
Original file line number Diff line number Diff line change
@@ -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 #缓存失效时间(单位:分钟)
Expand Down
8 changes: 7 additions & 1 deletion server/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 434eb25

Please sign in to comment.