# Rhai Scripting - URL in headers

**URL:** <https://community.apollographql.com/t/rhai-scripting-url-in-headers/7004>\
**Category:** Router\
**Tags:** router, rhai\
**Created:** [November 30, 2023, 4:19pm UTC](https://community.apollographql.com/t/rhai-scripting-url-in-headers/7004 "2023-11-30T16:19:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jessie\_Fanella](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/jessie_fanella/32/4776_2.png) [@Jessie\_Fanella](https://community.apollographql.com/u/Jessie_Fanella)\
**Post date:** [November 30, 2023, 4:19pm UTC](https://community.apollographql.com/t/rhai-scripting-url-in-headers/7004/1 "2023-11-30T16:19:13Z")

</div>

Hello, I am trying to set headers in a Rhai script. However, the headers are url’s. When I try to run my queries in the playground, I get this error:

`rhai execution error: 'Runtime error: invalid HTTP header name`

My code looks something like:

```auto
fn process_request(request) {
    let keys = request.context[context.here];
    }
    let key_users = ["https://url-one", "https://url-two"];
    for key_user in key_users {
      let key = keys[key_user];
      key = if key == () {""} else {key};
      request.subgraph.headers[key_user] = key;
     };
}

```

I’ve been referencing [this](https://www.apollographql.com/docs/router/customizations/rhai/) but not having much luck

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/rhai-scripting-url-in-headers/7004/2 "2025-02-06T20:48:01Z")

</div>

Archived on February 6, 2025, 8:48pm UTC


