Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions testing/script/javascript-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
| ------------------------------ | -------------------------------------------------------------------- |
| req.getUrl() | Get the current request URL. |
| req.setUrl(url) | Set the current request URL. |
| req.getHost() | Get the hostname from the request URL. |

Check warning on line 23 in testing/script/javascript-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (bruno-a6972042) - vale-spellcheck

testing/script/javascript-reference.mdx#L23

Did you really mean 'hostname'?
| req.getPath() | Get the path from the request URL. |
| req.getQueryString() | Get the raw query string from the request URL. |
| req.getPathParams() | Extract path parameters using the path template. |
Expand Down Expand Up @@ -58,7 +58,7 @@
req.setUrl("https://api.github.com/search/repositories?q=vue");
```

- **`getHost()`** - Get the hostname from the request URL.

Check warning on line 61 in testing/script/javascript-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (bruno-a6972042) - vale-spellcheck

testing/script/javascript-reference.mdx#L61

Did you really mean 'hostname'?
```javascript
const host = req.getHost();
console.log("Host:", host);
Expand Down Expand Up @@ -965,6 +965,22 @@
});
```

<Info>
**`__Host-` prefixed cookies:** Bruno supports storing cookies with the `__Host-` prefix via the script API. Per the cookie spec, `__Host-` cookies must be host-only (no explicit `domain`). When you set a cookie whose name starts with `__Host-`, Bruno automatically omits the `domain` attribute so it is derived from the request URL. Do not set a `domain` property on `__Host-` prefixed cookies — if you do, the cookie will be rejected.
</Info>

```javascript
// Example: setting a __Host- prefixed cookie
const jar = bru.cookies.jar();
jar.setCookie("https://example.com", {
key: "__Host-SESSION",
value: "token123",
path: "/",
secure: true
// Do not set 'domain' — it is derived from the URL automatically
});
```

- **`jar.setCookies(url, cookies)`** - Set multiple cookies at once using an array of cookie objects.

**Parameters:**
Expand Down