diff --git a/CHANGELOG.md b/CHANGELOG.md index 856a7a92..31243385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.19 (WIP) + +* Fix `Conduit#parseUrl()` not being able to parse the host & protocol of http2 requests + ## 1.3.18 (2023-10-17) * Add `Alchemy#setMaxEventLoopLag(max_lag)` method diff --git a/lib/class/conduit.js b/lib/class/conduit.js index 7073b12b..44a4cc4a 100644 --- a/lib/class/conduit.js +++ b/lib/class/conduit.js @@ -550,11 +550,11 @@ Conduit.setMethod(async function parseRequest() { }); /** - * Parse the url if it hasn't been done already + * Parse the complete request URL if it hasn't been done yet * * @author Jelle De Loecker * @since 1.3.18 - * @version 1.3.18 + * @version 1.3.19 */ Conduit.setMethod(function parseUrl() { @@ -569,6 +569,8 @@ Conduit.setMethod(function parseUrl() { protocol = 'https://'; } else if (this.headers['x-forwarded-proto']) { protocol = this.headers['x-forwarded-proto']; + } else if (this.headers[':scheme']) { + protocol = this.headers[':scheme']; } else if (this.protocol) { protocol = this.protocol; } else if (this.encrypted) { @@ -583,21 +585,19 @@ Conduit.setMethod(function parseUrl() { // Set the protocol this.url.protocol = protocol; + // Get the host/domain/authority of the request + const host = this.headers[':authority'] || this.headers.host; + // Set the host - this.url.hostname = this.headers.host; + this.url.hostname = host; // If no URL was set, use the first requests URL (without the path) - if (!alchemy.settings.url && this.headers.host) { + if (!alchemy.settings.url && host) { alchemy.setUrl(this.url); } - let path = this.original_path; - - if (this.prefix) { - path = '/' + this.prefix + '/' + path; - } - - this.url.path = path; + // Set the entire original path + this.url.path = this.original_path; return true; }); diff --git a/package.json b/package.json index 86aedb07..e9dcd386 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alchemymvc", "description": "MVC framework for Node.js", - "version": "1.3.18", + "version": "1.3.19-alpha", "author": "Jelle De Loecker ", "keywords": [ "alchemy",