vona-core 5.1.39 → 5.1.41
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/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/core/application.d.ts.map +1 -1
- package/dist/lib/core/context.d.ts.map +1 -1
- package/dist/types/context/contextBase.d.ts +5 -0
- package/dist/types/context/contextBase.d.ts.map +1 -1
- package/dist/types/context/index.d.ts +1 -0
- package/dist/types/context/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/lib/core/application.ts +12 -5
- package/src/lib/core/context.ts +7 -6
- package/src/types/context/contextBase.ts +6 -0
- package/src/types/context/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -2287,16 +2287,18 @@ const contextBase = {
|
|
|
2287
2287
|
if (self.accepts('html', 'text', 'json') === 'json') return true;
|
|
2288
2288
|
return false;
|
|
2289
2289
|
},
|
|
2290
|
-
redirect(url,
|
|
2290
|
+
redirect(url, statusOrOptions) {
|
|
2291
2291
|
const self = cast(this);
|
|
2292
|
+
const options = typeof statusOrOptions === 'number' ? {
|
|
2293
|
+
status: statusOrOptions
|
|
2294
|
+
} : statusOrOptions ?? {};
|
|
2292
2295
|
// checkOrigin
|
|
2293
|
-
if (!url.startsWith('/')) {
|
|
2294
|
-
const origin = cast(self.app.bean).security.checkOrigin(url, self.host);
|
|
2296
|
+
if (!url.startsWith('/') && !options.trustedExternal) {
|
|
2297
|
+
const origin = cast(self.app.bean).security.checkOrigin(url, self.app.util.host);
|
|
2295
2298
|
if (!origin) self.app.throw(403);
|
|
2296
2299
|
}
|
|
2297
2300
|
// throw
|
|
2298
|
-
status
|
|
2299
|
-
self.app.throw(status, url);
|
|
2301
|
+
self.app.throw(options.status ?? 302, url);
|
|
2300
2302
|
}
|
|
2301
2303
|
};
|
|
2302
2304
|
|
|
@@ -2676,22 +2678,29 @@ class VonaApplication extends KoaApplication {
|
|
|
2676
2678
|
if (req) {
|
|
2677
2679
|
request = req;
|
|
2678
2680
|
} else {
|
|
2679
|
-
const
|
|
2681
|
+
const port = this.config?.server.listen.port ?? this.meta.env.SERVER_LISTEN_PORT;
|
|
2682
|
+
const hostFallback = port ? `localhost:${port}` : 'localhost';
|
|
2683
|
+
const protocol = (this.config ? this.util.protocol : undefined) || 'http';
|
|
2684
|
+
const host = (this.config ? this.util.host : undefined) || hostFallback;
|
|
2685
|
+
const hostname = new URL(`${protocol}://${host}`).hostname;
|
|
2680
2686
|
request = {
|
|
2681
2687
|
headers: {
|
|
2682
2688
|
'host': host,
|
|
2683
|
-
'x-forwarded-for':
|
|
2689
|
+
'x-forwarded-for': '127.0.0.1',
|
|
2690
|
+
'x-forwarded-host': host,
|
|
2691
|
+
'x-forwarded-proto': protocol
|
|
2684
2692
|
},
|
|
2685
2693
|
query: {},
|
|
2686
2694
|
querystring: '',
|
|
2687
2695
|
host,
|
|
2688
|
-
hostname
|
|
2689
|
-
protocol
|
|
2690
|
-
secure: '
|
|
2696
|
+
hostname,
|
|
2697
|
+
protocol,
|
|
2698
|
+
secure: protocol === 'https',
|
|
2691
2699
|
method: 'POST',
|
|
2692
2700
|
url: '',
|
|
2693
2701
|
path: '',
|
|
2694
2702
|
socket: {
|
|
2703
|
+
encrypted: protocol === 'https',
|
|
2695
2704
|
remoteAddress: '127.0.0.1',
|
|
2696
2705
|
remotePort: 7001
|
|
2697
2706
|
}
|