vona-core 5.1.40 → 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 CHANGED
@@ -2294,7 +2294,7 @@ const contextBase = {
2294
2294
  } : statusOrOptions ?? {};
2295
2295
  // checkOrigin
2296
2296
  if (!url.startsWith('/') && !options.trustedExternal) {
2297
- const origin = cast(self.app.bean).security.checkOrigin(url, self.host);
2297
+ const origin = cast(self.app.bean).security.checkOrigin(url, self.app.util.host);
2298
2298
  if (!origin) self.app.throw(403);
2299
2299
  }
2300
2300
  // throw
@@ -2678,22 +2678,29 @@ class VonaApplication extends KoaApplication {
2678
2678
  if (req) {
2679
2679
  request = req;
2680
2680
  } else {
2681
- const host = `localhost:${this.meta.env.SERVER_LISTEN_PORT}`;
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;
2682
2686
  request = {
2683
2687
  headers: {
2684
2688
  'host': host,
2685
- 'x-forwarded-for': host
2689
+ 'x-forwarded-for': '127.0.0.1',
2690
+ 'x-forwarded-host': host,
2691
+ 'x-forwarded-proto': protocol
2686
2692
  },
2687
2693
  query: {},
2688
2694
  querystring: '',
2689
2695
  host,
2690
- hostname: 'localhost',
2691
- protocol: 'http',
2692
- secure: 'false',
2696
+ hostname,
2697
+ protocol,
2698
+ secure: protocol === 'https',
2693
2699
  method: 'POST',
2694
2700
  url: '',
2695
2701
  path: '',
2696
2702
  socket: {
2703
+ encrypted: protocol === 'https',
2697
2704
  remoteAddress: '127.0.0.1',
2698
2705
  remotePort: 7001
2699
2706
  }