Reputation: 777
I have a dist folder in my Go project. That contain angular build files.
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/contrib/static"
"github.com/gin-gonic/gin"
)
func SetRoutes() *gin.Engine {
router := gin.Default()
router.Use(cors.Default())
router.Use(static.Serve("/", static.LocalFile("./client/dist", true)))
router.Run(":8080")
}
Using above code I can serve dist folder files. But if I refresh browser, it will not get those files. Shows error "404 page not found".
Upvotes: 0
Views: 922
Reputation: 131
adding to @Dulquer answer make sure 'dist' folder contains 'index.html' file as direct child because 'ng build' creates a folder with the 'your-project-name' containing 'index.html' and places in 'dist' folder.
Upvotes: 0