@jayfong/x-server 2.35.1 → 2.36.0
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.
|
@@ -355,10 +355,10 @@ class ApiGenerator {
|
|
|
355
355
|
},
|
|
356
356
|
paths: {},
|
|
357
357
|
servers: [{
|
|
358
|
-
url: `${process.env.APP_URL}
|
|
358
|
+
url: `${process.env.APP_URL}`.replace(/\/+$/, ''),
|
|
359
359
|
description: '生产'
|
|
360
360
|
}, {
|
|
361
|
-
url: `http://127.0.0.1:${process.env.APP_PORT}
|
|
361
|
+
url: `http://127.0.0.1:${process.env.APP_PORT}`,
|
|
362
362
|
description: '本地'
|
|
363
363
|
}]
|
|
364
364
|
};
|
package/lib/_cjs/core/server.js
CHANGED
|
@@ -113,7 +113,7 @@ class Server {
|
|
|
113
113
|
url: url,
|
|
114
114
|
headers: req.headers,
|
|
115
115
|
setHeader: (k, v) => res.header(k, v),
|
|
116
|
-
redirect: url => res.redirect(url),
|
|
116
|
+
redirect: (url, permanently) => res.redirect(permanently ? 301 : 302, url),
|
|
117
117
|
ws: undefined,
|
|
118
118
|
req: req,
|
|
119
119
|
res: res
|
package/lib/cli/api_generator.js
CHANGED
|
@@ -350,10 +350,10 @@ export class ApiGenerator {
|
|
|
350
350
|
},
|
|
351
351
|
paths: {},
|
|
352
352
|
servers: [{
|
|
353
|
-
url: `${process.env.APP_URL}
|
|
353
|
+
url: `${process.env.APP_URL}`.replace(/\/+$/, ''),
|
|
354
354
|
description: '生产'
|
|
355
355
|
}, {
|
|
356
|
-
url: `http://127.0.0.1:${process.env.APP_PORT}
|
|
356
|
+
url: `http://127.0.0.1:${process.env.APP_PORT}`,
|
|
357
357
|
description: '本地'
|
|
358
358
|
}]
|
|
359
359
|
};
|
package/lib/core/server.js
CHANGED
|
@@ -107,7 +107,7 @@ export class Server {
|
|
|
107
107
|
url: url,
|
|
108
108
|
headers: req.headers,
|
|
109
109
|
setHeader: (k, v) => res.header(k, v),
|
|
110
|
-
redirect: url => res.redirect(url),
|
|
110
|
+
redirect: (url, permanently) => res.redirect(permanently ? 301 : 302, url),
|
|
111
111
|
ws: undefined,
|
|
112
112
|
req: req,
|
|
113
113
|
res: res
|
package/lib/core/types.d.ts
CHANGED
|
@@ -77,8 +77,11 @@ export declare namespace XHandler {
|
|
|
77
77
|
setHeader: (key: string, value: string) => void;
|
|
78
78
|
/**
|
|
79
79
|
* HTTP 跳转
|
|
80
|
+
*
|
|
81
|
+
* 默认是临时跳转,状态码是 302,
|
|
82
|
+
* 可将第二个参数设为 true 表示永久跳转,状态码是 301
|
|
80
83
|
*/
|
|
81
|
-
redirect: (url: string) => void;
|
|
84
|
+
redirect: (url: string, permanently?: boolean) => void;
|
|
82
85
|
/**
|
|
83
86
|
* WS
|
|
84
87
|
*/
|