vona-core 5.1.41 → 5.1.42

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
@@ -234,11 +234,16 @@ class AppUtil extends BeanSimple {
234
234
  }
235
235
  get protocol() {
236
236
  const config = this.ctx ? this.ctx.config : this.app.config;
237
- return config.server.serve.protocol || this.ctx?.protocol;
237
+ return config.server.serve.protocol || this.ctx?.protocol || 'http';
238
238
  }
239
239
  get host() {
240
240
  const config = this.ctx ? this.ctx.config : this.app.config;
241
- return config.server.serve.host || this.ctx?.host;
241
+ let host = config.server.serve.host || this.ctx?.host;
242
+ if (!host) {
243
+ const port = this.app.meta.env.SERVER_LISTEN_PORT;
244
+ host = port ? `localhost:${port}` : 'localhost';
245
+ }
246
+ return host;
242
247
  }
243
248
  getAbsoluteUrl(path) {
244
249
  const prefix = this.host ? `${this.protocol}://${this.host}` : '';
@@ -2678,10 +2683,9 @@ class VonaApplication extends KoaApplication {
2678
2683
  if (req) {
2679
2684
  request = req;
2680
2685
  } else {
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;
2686
+ const protocol = 'http';
2687
+ const port = this.meta.env.SERVER_LISTEN_PORT;
2688
+ const host = port ? `localhost:${port}` : 'localhost';
2685
2689
  const hostname = new URL(`${protocol}://${host}`).hostname;
2686
2690
  request = {
2687
2691
  headers: {
@@ -2695,12 +2699,12 @@ class VonaApplication extends KoaApplication {
2695
2699
  host,
2696
2700
  hostname,
2697
2701
  protocol,
2698
- secure: protocol === 'https',
2702
+ secure: false,
2699
2703
  method: 'POST',
2700
2704
  url: '',
2701
2705
  path: '',
2702
2706
  socket: {
2703
- encrypted: protocol === 'https',
2707
+ encrypted: false,
2704
2708
  remoteAddress: '127.0.0.1',
2705
2709
  remotePort: 7001
2706
2710
  }