Gin: How do you solve vue.js HTML5 History Mode?

Created on 31 Jul 2017  路  3Comments  路  Source: gin-gonic/gin

https://router.vuejs.org/en/essentials/history-mode.html

How do you solve vue.js HTML5 History Mode?

question

Most helpful comment

@boneq As the vuejs docs say, returning the index.html of your web app when no other route is matched, is the way to go. It can ve achieved like below:

r.Use(static.Serve("/", static.LocalFile("/src", false)))
r.NoRoute(func(c *gin.Context){
    c.File("/src/index.html")
})

All 3 comments

@boneq As the vuejs docs say, returning the index.html of your web app when no other route is matched, is the way to go. It can ve achieved like below:

r.Use(static.Serve("/", static.LocalFile("/src", false)))
r.NoRoute(func(c *gin.Context){
    c.File("/src/index.html")
})

PD: static is the middleware from https://github.com/gin-contrib/static

OK, I'll try it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

atifzia picture atifzia  路  3Comments

sofish picture sofish  路  3Comments

gplume picture gplume  路  3Comments

frederikhors picture frederikhors  路  3Comments

oryband picture oryband  路  3Comments