mirror of
https://github.com/XShengTech/MEGREZ.git
synced 2026-01-13 16:47:16 +08:00
[Fix] 🐛 Cors Error at FrontEnd
This commit is contained in:
parent
87995f0572
commit
1f55ecb649
12
routers/index/cors.go
Normal file
12
routers/index/cors.go
Normal file
@ -0,0 +1,12 @@
|
||||
package index
|
||||
|
||||
import "github.com/kataras/iris/v12"
|
||||
|
||||
func cors(ctx iris.Context) {
|
||||
ctx.Header("Access-Control-Allow-Origin", "*")
|
||||
ctx.Header("Access-Control-Allow-Methods", "GET")
|
||||
ctx.Header("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||
ctx.Header("Access-Control-Max-Age", "86400")
|
||||
ctx.Header("Access-Control-Allow-Credentials", "true")
|
||||
ctx.Next()
|
||||
}
|
||||
@ -5,6 +5,7 @@ import (
|
||||
)
|
||||
|
||||
func InitIndex(app *iris.Application) {
|
||||
app.Use(cors)
|
||||
app.HandleDir("/", GetWebFS(), iris.DirOptions{
|
||||
IndexName: "/index.html",
|
||||
Compress: true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user