nuxt-gin-tools 0.2.8 → 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 +1 -1
- package/src/nuxt-config.d.ts +0 -63
- package/src/nuxt-config.js +7 -3
package/package.json
CHANGED
package/src/nuxt-config.d.ts
CHANGED
|
@@ -61,66 +61,3 @@ export interface MyNuxtConfig {
|
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
63
|
export function createDefaultConfig(config: MyNuxtConfig): NuxtConfig;
|
|
64
|
-
srcDir: string;
|
|
65
|
-
ssr: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* 配置实验性功能
|
|
68
|
-
* 禁用 payloadExtraction 功能,该功能可能用于提取页面的有效负载数据
|
|
69
|
-
* 这里禁用它可能是为了避免某些兼容性问题或特定的项目需求
|
|
70
|
-
*/
|
|
71
|
-
experimental: {
|
|
72
|
-
payloadExtraction: boolean;
|
|
73
|
-
};
|
|
74
|
-
devtools: {
|
|
75
|
-
timeline: {
|
|
76
|
-
enabled: boolean;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* 配置应用的基础 URL
|
|
81
|
-
* 从 server.config.json 文件中获取 baseUrl 作为应用的基础 URL
|
|
82
|
-
* 这个基础 URL 将用于构建应用的路由和请求地址
|
|
83
|
-
*/
|
|
84
|
-
app: {
|
|
85
|
-
baseURL: string;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* 配置开发服务器的端口号
|
|
89
|
-
* 从 server.config.json 文件中获取 nuxtPort 作为开发服务器的端口号
|
|
90
|
-
* 启动开发服务器时,将使用该端口号进行监听
|
|
91
|
-
*/
|
|
92
|
-
devServer: {
|
|
93
|
-
port: number;
|
|
94
|
-
cors: {
|
|
95
|
-
origin: string;
|
|
96
|
-
methods: string[];
|
|
97
|
-
allowHeaders: string[];
|
|
98
|
-
credentials: boolean;
|
|
99
|
-
maxAge: string;
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
nitro: {
|
|
103
|
-
output: {
|
|
104
|
-
dir: string;
|
|
105
|
-
};
|
|
106
|
-
devProxy: Record<string, {
|
|
107
|
-
target: string;
|
|
108
|
-
changeOrigin: boolean;
|
|
109
|
-
ws: boolean;
|
|
110
|
-
}>;
|
|
111
|
-
};
|
|
112
|
-
vite: {
|
|
113
|
-
server: {
|
|
114
|
-
proxy: Record<string, {
|
|
115
|
-
target: string;
|
|
116
|
-
changeOrigin: boolean;
|
|
117
|
-
ws: boolean;
|
|
118
|
-
}>;
|
|
119
|
-
};
|
|
120
|
-
plugins: never[];
|
|
121
|
-
esbuild: {
|
|
122
|
-
jsxFactory: string;
|
|
123
|
-
jsxFragment: string;
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
};
|
package/src/nuxt-config.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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(
|
|
66
|
+
target: buildTarget(),
|
|
63
67
|
changeOrigin: true,
|
|
64
68
|
ws: true,
|
|
65
69
|
};
|