How to serve a next js application with gorilla mux in Golang instead of the native go http package?

huangapple go评论69阅读模式
英文:

How to serve a next js application with gorilla mux in Golang instead of the native go http package?

问题

我有一个Go后端,在我的控制器中有一个routes.go文件,使用gorilla mux路由器。我该如何使用gorilla mux来提供一个静态的Next.js应用程序?

英文:

I have a go backend and inside my controllers i have a routes.go that uses gorilla mux router. How can i serve a static next js application using gorilla mux?

答案1

得分: 1

s.Router.PathPrefix("/").Handler(http.FileServer(http.Dir("nextjs/dist"))))

这是我用来提供静态 Next.js 文件的方法。

英文:

s.Router.PathPrefix("/").Handler(http.FileServer(http.Dir("nextjs/dist")))
That's how i managed to serve the static next.js

huangapple
  • 本文由 发表于 2022年6月22日 22:43:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/72717613.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定