1234567891011121314151617181920212223 |
- package main
- import (
- "cc-officialweb/middleware"
- _ "cc-officialweb/routers"
- beego "github.com/beego/beego/v2/server/web"
- "github.com/beego/beego/v2/server/web/filter/cors"
- )
- func main() {
- beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
- AllowAllOrigins: true,
- AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
- AllowHeaders: []string{"Origin", "Content-Type", "Authorization", "X-Requested-With"},
- ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin"},
- AllowCredentials: true,
- }))
- beego.InsertFilter("/api/*", beego.BeforeRouter, middleware.AuthMiddleware)
- beego.SetStaticPath("/image", "./static/upload")
- beego.SetStaticPath("/file", "./static/file")
- beego.SetStaticPath("/assets", "./static/assets")
- beego.Run()
- }
|