Need HTTP_REFERER parameter

I am trying to move my PHP service to Cloudflare workers. In PHP the code is working fine, but while rewriting the code for Cloudflare workers, I am stuck.
Basically, my code will run on multiple workers environments, and depending upon the path used to call the service, my code will act differently. I was fetching called URL in php using below code. but in js code for workers, I am not getting what alternate code should I use.

$referer_url = filter_var( $_SERVER[‘HTTP_REFERER’], FILTER_SANITIZE_STRING );

I am using “itty-router” template for my wranger code

router.get('/', (request, env, context) => {
  const referer = request.headers.get('referer');
})
2 Likes

Thanks, it helped.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.