main.go 651 B

1234567891011121314151617181920
  1. package main
  2. import (
  3. _ "cc-officialweb/routers"
  4. beego "github.com/beego/beego/v2/server/web"
  5. "github.com/beego/beego/v2/server/web/filter/cors"
  6. )
  7. func main() {
  8. beego.SetStaticPath("/image", "./static/upload")
  9. beego.SetStaticPath("/file", "./static/file")
  10. beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
  11. AllowAllOrigins: true,
  12. AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
  13. AllowHeaders: []string{"Origin", "Content-Type", "Authorization", "X-Requested-With"},
  14. ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin"},
  15. AllowCredentials: true,
  16. }))
  17. beego.Run()
  18. }