duan0417 2018-06-18 19:16
浏览 412

无法从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.

  • 写回答

2条回答 默认 最新

  • duankuiyuant3940 2018-06-18 20:45
    关注

    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).

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)