Skip to main content

Original Url

ยท One min read
Creator of Spider

I just added a link to the original URL of HTTP communication.
It was... missing, really!

I don't know why I did not add it before.
But here it comes!

UIโ€‹

OriginalUrl.png

How it worksโ€‹

It is very basic: Spider takes standard headers to rebuild the URL as it was requested by the client.

Here is the code if you want to do the same using the API resource:

const uri = item.req.uri;
const basePath = item.req.headers['x-forwarded-basepath'] || '';
const query = item.req.query ? '?'+item.req.query : '';
const hash = item.req.hash ? '#'+item.req.hash : '';
const host = item.req.headers.host;
const proto = item.req.headers['x-forwarded-proto'];

return `${proto || 'https'}://${host}${basePath}${uri}${query}${hash}`;

If the headers are not pushed by the proxy, the URL will be wrong.
Configure your proxy then! ๐Ÿ˜

Cheers,
Thibaut