1

I started to create a web app using Vue JS as the front end framework. In this process, I'm using Vue-Router to route paths to my vue components. And I'm serving this web app using Go with gorilla mux as my router.

Here I am not able to load any component to <router-view></router-view> in App.vue.

I found a similar question here. And I tried removing mode: 'history' but no luck. In the comments, it was mentioned that he let Go redirect all not-found URLs to /# + r.URL.Path. I didn't understand this bit.

I'll appreciate if anyone can guide me with some example.

Pramod
  • 121
  • 2
  • 16

1 Answers1

0

If possible, don't serve the front end from within the Go app. Here's what I do:

Go app is the backend, provides RESTful APIs for the front end to use.

There's a nginx server setup as a reverse proxy for the Go app.

nginx serves the front end directly

I use nginx to serve the Go backend in a certain url location or different port

masnun
  • 11,635
  • 4
  • 39
  • 50
  • `If possible, don't serve the front end from within the Go app.` why ? –  Oct 13 '19 at 09:43
  • 1
    Static content should served through a CDN or at least through nginx directly. Because nginx or a CDN would be more performant than a Go app. I don't want my Go functions executing for serving a simple css file. – masnun Oct 13 '19 at 14:52