A recent full stack project, photovoltaic cloud monitoring system, backend using Beego framework, pure API, front end using VUE2.0. Project Address: http://scada.ssechina.com:88/static
I put the packaged front-end files in the Go static directory,
Then main inside set
Beego. bconfig.webconfig.staticdir["/static"] = "static"
can only be accessed using ip/static/login.html.
If you change into
Beego. bconfig.webconfig.staticdir["/"] = "static"
I can't access it.
But there is a lot of static in the URL, and there are many files, such as verifying the site attribution, need to put a static file in the root directory, want to access static files directly from the root directory
Beego How do I use the root directory to access static files? It feels good to find the following on the internet and leave it to the next project:
Added the following code to the Main.go.
//Transparent staticBeego. Insertfilter ("/", Beego. Beforerouter, transparentstatic) Beego. Insertfilter ("/*", Beego. Beforerouter, Transparentstatic) func transparentstatic (CTX*context. Context) {ifStrings. Index (CTX. Request.URL.Path,"v1/") >=0 { return} http. Servefile (CTX. Responsewriter, CTX. Request,"static/"+CTX. Request.URL.Path)}
Vue packaged file deployment let Beego implement static file access, how to use root directory to access static files?