无法从Web应用程序连接到localhost:3000

I'm working on some boilerplate code to get a VueJS frontend working with a Go-powered backend (using gorilla/mux for a router):

Currently, I seem to have everything working for the most part. I'm serving a static HTML file via Go and rendering Vue stuff with it that's being bundled with webpack (webpack-dev-server currently, not a physical bundle), and I'm having a weird issue:

In my browser, Firefox keeps telling me the following:

Firefox can’t establish a connection to the server at http://localhost:3000/__webpack_hmr.

Yet, when I change Vue components and save them, they're auto-refreshing in the browser as I would expect. I'm really confused, I guess, I don't know why this is happening.

I've tried changing the port that my Go server operates on, and it always seems to fail connection at http://localhost:<Go Server Port>/__webpack_hmr.

Any thoughts? Maybe there's a step I'm missing or the setup is more complicated than I thought it was.

Do I need to be running an Express server and using the webpack-based Middleware to fix this error? If so, that sounds silly if I'm using Go for the backend (why would I run two servers?). Am I doing something wrong?

As for the Go side of things, I've tried both running the Go server on a different port and having the webpack server run on different ports and such, but it always fails to connect at http://localhost:<Go Server Port>/__webpack_hmr.

Maybe this is more complicated to set up than I thought it was, or since it seems to be "working", I can safely ignore this error? I dunno.

Remove 'webpack-hot-middleware/client' from your webpack config and any references in your codebase. This is only used for hot reloading, so it's safe to remove it.

Since you need hot reloading, you should use: https://github.com/go-webpack/webpack

This module allows proper integration with webpack, with support for proper assets reloading in development and asset hashes for production caching.

However they only show examples using Gin and Iris, so you may need to open an issue with them for an example based on purely net/http (assuming that's what you're using).

if I understand your issue correctly. your client and server use a different port and if it is the case then you're using CORS(Cross-Origin Resource Sharing) request to communicate with client-server. see the following links hope it will help you to fix CORS issue(It helps me a lot)