How can I deploy my project to serverless functions without “unable to match html templates” error?
I have my code setup so it finds external html file templates in the “external/html” directory using the LoadHtmlGlob
function gin provides.
Instead of loading and serving the html content, it instead errors saying that the pattern provided can’t find any files.
// api/index.go
func Handler(w http.ResponseWriter, req *http.Request) {
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
r.Use(Cors())
r.LoadHtmlGlob("/external/html/*.html")
//***
}
//vercel.json
{
"version": 2,
"routes": [
{
"src": "/(.*)",
"dest": "/api/index.go"
}
]
}
Project structure:
.
├── api
│ └── index.go
├── external
│ ├── html
│ ├── models
│ └── util
│ ├── bucket.go
│ ├── database.go
│ └── redis.go
├── .env.local
├── .env.prod
├── .gitignore
├── go.mod
└── go.sum