Vue packaged file deployment let Beego implement static file access, how to use root directory to access static files?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.