mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
requestUtils: add some logging to allowHost
I found it useful during my work to figure out what was going on in this function and why some requests were being denied.
This commit is contained in:
parent
6f4637a8f0
commit
17ea97db78
@ -103,6 +103,12 @@ export function allowHost(req: IncomingMessage, allowedHost: string|URL) {
|
|||||||
const proto = getEndUserProtocol(req);
|
const proto = getEndUserProtocol(req);
|
||||||
const actualUrl = new URL(getOriginUrl(req));
|
const actualUrl = new URL(getOriginUrl(req));
|
||||||
const allowedUrl = (typeof allowedHost === 'string') ? new URL(`${proto}://${allowedHost}`) : allowedHost;
|
const allowedUrl = (typeof allowedHost === 'string') ? new URL(`${proto}://${allowedHost}`) : allowedHost;
|
||||||
|
log.rawDebug('allowHost: ', {
|
||||||
|
req: (new URL(req.url!, `http://${req.headers.host}`).href),
|
||||||
|
origin: req.headers.origin,
|
||||||
|
actualUrl: actualUrl.hostname,
|
||||||
|
allowedUrl: allowedUrl.hostname,
|
||||||
|
});
|
||||||
if ((req as RequestWithOrg).isCustomHost) {
|
if ((req as RequestWithOrg).isCustomHost) {
|
||||||
// For a request to a custom domain, the full hostname must match.
|
// For a request to a custom domain, the full hostname must match.
|
||||||
return actualUrl.hostname === allowedUrl.hostname;
|
return actualUrl.hostname === allowedUrl.hostname;
|
||||||
|
Loading…
Reference in New Issue
Block a user