nuxt-gin-tools 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-gin-tools",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "This project is used as a dependency for [nuxt-gin-starter](https://github.com/RapboyGao/nuxt-gin-starter.git)",
5
5
  "bin": {
6
6
  "nuxt-gin": "index.js"
@@ -41,14 +41,18 @@ function createDefaultConfig({ serverConfig, apiBasePath, wsProxyBasePaths = [],
41
41
  return "/";
42
42
  return trimmed.endsWith("/") ? trimmed.slice(0, -1) : trimmed;
43
43
  };
44
- const buildTarget = (basePath) => `http://localhost:${serverConfig.ginPort}${basePath}`;
44
+ // Proxy target should point to backend origin only.
45
+ // The matched route prefix (e.g. /api-go/v1, /ws-go) is preserved by proxy itself.
46
+ // If target also appends basePath, final upstream path becomes duplicated and can
47
+ // break websocket upgrades with ECONNRESET.
48
+ const buildTarget = () => `http://127.0.0.1:${serverConfig.ginPort}`;
45
49
  /**
46
50
  * 目标服务器的 URL
47
51
  * 格式为:http://localhost:ginPort/serverBasePath
48
52
  * 其中,ginPort 是从 serverConfig 中获取的 Gin 服务器的端口号
49
53
  * serverBasePath 是从 MyNuxtConfig 中获取的服务器基础路径
50
54
  */
51
- const target = buildTarget(normalizedProxyBasePath);
55
+ const target = buildTarget();
52
56
  const proxyEntries = {
53
57
  [normalizedProxyBasePath]: {
54
58
  target,
@@ -59,7 +63,7 @@ function createDefaultConfig({ serverConfig, apiBasePath, wsProxyBasePaths = [],
59
63
  for (const rawPath of wsProxyBasePaths) {
60
64
  const normalizedPath = normalizeBasePath(rawPath);
61
65
  proxyEntries[normalizedPath] = {
62
- target: buildTarget(normalizedPath),
66
+ target: buildTarget(),
63
67
  changeOrigin: true,
64
68
  ws: true,
65
69
  };