0
votes

I have a Vuejs app that I'm trying to serve via a Golang backend that will also serve the app's API.

When I build and run the Vuejs via "npm run build" and "serve -s dist" and go to the static server's location, everything loads up fine. But when I try to load it through the Golang backend, even though the index.html loads (as verified by checking the source in the browser), I just get a blank white page.

Is this approach not possible? Am I going about this all wrong?

Here is how I am serving the "dist" folder via Golang.

http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir(htmlFolder+"/dist/"))))

My index.html file:

<!DOCTYPE html>
<html lang=en>
<head>
    <meta charset=utf-8>
    <meta http-equiv=X-UA-Compatible content="IE=edge">
    <meta name=viewport content="width=device-width,initial-scale=1">
    <link rel=icon href=/favicon.ico>
    <title>TestApp</title>
    <link href=/css/app.52c62e82.css rel=preload as=style>
    <link href=/css/chunk-vendors.7724753e.css rel=preload as=style>
    <link href=/js/app.9a3ab992.js rel=preload as=script>
    <link href=/js/chunk-vendors.6808fe3a.js rel=preload as=script>
    <link href=/css/chunk-vendors.7724753e.css rel=stylesheet>
    <link href=/css/app.52c62e82.css rel=stylesheet>
</head>
<body>
    <noscript>
        <strong>We're sorry but TestApp doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id=app></div>
    <script src=/js/chunk-vendors.6808fe3a.js></script>
    <script src=/js/app.9a3ab992.js></script>
</body>
</html>

Edit:

I also tried using gorilla/mux example here: https://blog.questionable.services/article/vue-react-ember-server-golang/

And here is my "dist"'s folder structure.

enter image description here

2

2 Answers

1
votes

press F12 on your browser and go to console tab to view the error

0
votes

Turns out I just needed to empty my caches. I was using FN5 when refreshing assuming that that would reload it.