title: vue-router in production (serving with Go)
body: <p>I'd like to separate client and server completely, so I created a vuejs project with <code>vue init webpack my-project</code>. In this project I'm using vue-router for all my routing (this includes special paths, like <code>/user/SOMEID</code>..</p>
  
  <p>This is my routes.js file:</p>
  
  <pre><code>import App from './App.vue'
  
  export const routes = [
    {
      path: '/',
      component: App.components.home
    },
    {
      path: '/user/:id',
      component: App.components.userid
    },
    {
      path: '*',
      component: App.components.notFound
    }
  ]
  </code></pre>
  
  <p>When I run the application using <code>npm run dev</code> everything works perfectly.  I'm now ready to deploy to cloud, so I ran <code>npm run build</code>. Since I need to use a HTTP Server, I decided to use Go for that as well.. this is my Go file:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "github.com/go-chi/chi"
      "github.com/me/myproject/server/handler"
      "net/http"
      "strings"
  )
  
  func main() {
      r := chi.NewRouter()
  
      distDir := "/home/me/code/go/src/github.com/me/myproject/client/dist/static"
      FileServer(r, "/static", http.Dir(distDir))
  
      r.Get("/", IndexGET)
  
      http.ListenAndServe(":8080", r)
  }
  
  func IndexGET(w http.ResponseWriter, r *http.Request) {
      handler.Render.HTML(w, http.StatusOK, "index", map[string]interface{}{})
  }
  
  func FileServer(r chi.Router, path string, root http.FileSystem) {
      if strings.ContainsAny(path, "{}*") {
          panic("FileServer does not permit URL parameters.")
      }
  
      fs := http.StripPrefix(path, http.FileServer(root))
  
      if path != "/" &amp;&amp; path[len(path)-1] != '/' {
          r.Get(path, http.RedirectHandler(path+"/", 301).ServeHTTP)
          path += "/"
      }
      path += "*"
  
      r.Get(path, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
          fs.ServeHTTP(w, r)
      }))
  }
  </code></pre>
  
  <p>I'm able to load the home page (<code>App.components.home</code>) where everything seem to work (the css, the images, translations, calls to and responses from the server).. but when I try to open other routes that should either result in 404 or load a user, then I just get the response <code>404 page not found</code> in plaintext (not the vue notFound component it's supposed to render)..</p>
  
  <p>Any ideas what I'm doing wrong and how to fix it?</p>
  
  <hr>
  
  <p>Edit: this is the other part of the router setup in the main.js file:</p>
  
  <pre><code>const router = new VueRouter({
    mode: 'history',
    base: __dirname,
    routes
  })
  
  new Vue({
    el: '#app',
    router,
    i18n,
    render: h =&gt; h(App)
  })
  </code></pre>