我正在编写一个 api 服务器,用于通过 go-gin 框架上传和提供视频和图像。我已将我的视频上传到另一个主机,并且它有效
router := gin.Default()
//config := cors.DefaultConfig()
//config.AllowAllOrigins = true
routerConfig := cors.Config{
AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"},
AllowHeaders: []string{"X-Requested-With", "Authorization", "Origin", "Content-Length", "Content-Type"},
AllowCredentials: false,
MaxAge: 12 * time.Hour,
}
router.Use(cors.New(routerConfig))
router.StaticFS("/public", http.Dir("static"))
err := router.Run(":5000")
if err != nil {
panic(err)
}
当我尝试http://localhost:5000/public/{image_url}.png通过铬访问时。它加载到浏览器。但是当我http://localhost:5000/public/{video_url}.mp4通过 chromium 访问时,它无法从浏览器加载任何内容(它无法接收)
有人可以为我解释我做错了什么吗?
哔哔one
手掌心
随时随地看视频慕课网APP
相关分类