Add two new $_SERVER variables: req.protocol and req.protocol+'://'+req.headers['host']

Can you add to the core the protocol used? Useful when building URLs.

For nodejs it would be HTTP_PROTOCOL: req.protocol

We can workaround it by using ternary on $_SERVER.HTTPS but seeing how it is actually built HTTPS: req.protocol == 'https'it seems kind of ironic :slight_smile:

Anyway I added it to my core files but it would be nice if they don’t get overwritten on next update :slight_smile:

Additionally this one would be nice too:

HTTP_BASE_URL: req.protocol+'://'+req.headers['host'],

Should not use the HTTP_ prefix for these. They contain actually the request headers.

HTTP_< HeaderName > The value stored in the header HeaderName . Any header other than those listed in this table must be prefixed by HTTP_ in order for the ServerVariables collection to retrieve its value.

Will add the req.protocol as REQUEST_PROTOCOL and the other as BASE_URL.

1 Like

This has been added in Wappler 3.4.0

1 Like