mirror of
https://github.com/XShengTech/MEGREZ.git
synced 2026-05-03 13:02:38 +00:00
[Fix] 🐛 Cors Error at FrontEnd
This commit is contained in:
@@ -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) {
|
func InitIndex(app *iris.Application) {
|
||||||
|
app.Use(cors)
|
||||||
app.HandleDir("/", GetWebFS(), iris.DirOptions{
|
app.HandleDir("/", GetWebFS(), iris.DirOptions{
|
||||||
IndexName: "/index.html",
|
IndexName: "/index.html",
|
||||||
Compress: true,
|
Compress: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user