hCaptcha assethost and the custom host parameters.
assethost is an optional hCaptcha setting that changes where the
widget loads its assets from. Enterprise sites use it, with a few related
options, to serve hCaptcha through their own domain. hCaptcha keeps the
per-parameter reference in its Enterprise docs, which are not on its public
docs site, so this page collects what it says in public, read on 1 November 2026.
The related options are imghost, endpoint,
reportapi, host and apihost, plus the
sentry switch. The public sources are hCaptcha’s docs, its FAQ,
and the props tables and source of its own SDKs.
The parameters
Every hCaptcha SDK that exposes these options lists them with the same note,
“See enterprise docs”. The one sentence that covers the whole group is in the
React SDK README: scriptSource,
apihost, assethost, endpoint,
host, imghost and reportapi “control
where hCaptcha assets and API requests are loaded from.” The types below come
from the same tables; the Android SDK types the URL options as
String (URL) and host as a bare hostname.
| Parameter | Type | What hCaptcha documents publicly |
|---|---|---|
assethost | string (URL) | One of the options that “control where hCaptcha assets and API requests are loaded from”. Listed in the loader, React, Vue and Android SDKs as “See enterprise docs”. |
imghost | string (URL) | Same group and same note. Listed in the loader, React, Vue and Android SDKs. |
endpoint | string (URL) | Same group and same note. Listed in the loader, React, Vue and Android SDKs. |
reportapi | string (URL) | Same group and same note. Listed in the loader, React, Vue and Android SDKs. |
host | string (hostname) | Same group. The Android SDK adds: “Do not include scheme; remove http(s)://.” |
apihost | string (URL) | Same group. In the loader it is the origin api.js is fetched from; the default is https://js.hcaptcha.com. |
scriptSource (Android: jsSrc) | string (URL) | The full script URL, default https://js.hcaptcha.com/1/api.js. Takes precedence over secureApi. Android’s older apiEndpoint is deprecated in its favour. |
sentry | boolean | Client-side error reporting to hCaptcha. Setting it to false “will prevent client-side error reports from being sent to us”. React defaults it to true. |
The tables also list custom, uj (React:
userJourneys) and secureApi under the same Enterprise
note. They do not change hosts, so this page leaves them out. The standard
script parameters (onload, render, hl,
recaptchacompat) are in hCaptcha’s
configuration reference.
When a site uses them
Out of the box, the widget loads from js.hcaptcha.com and talks
to hCaptcha’s own hosts. hCaptcha’s public docs describe three Enterprise
setups that serve it from somewhere else:
-
The Enterprise overview says
First-Party Proxy lets “users
connect to
hcaptcha.your.com, keeping all requests and assets under your domain”. Because users connect to your servers, you can also remove data such as the user’s IP before anything reaches hCaptcha. -
For users in China, the FAQ lists “regional
endpoints and our First-Party Hosting feature” and sends Enterprise
customers to
support@hcaptcha.comto set them up. - The same FAQ offers support for deprecated operating systems and browsers through the First-Party feature, “enabling you to serve hCaptcha using your own certificates”.
The host options are how a page points the widget at that infrastructure. hCaptcha does not publish which values go into which option for each setup; they come with the Enterprise onboarding. A site on hCaptcha’s default hosts needs none of the host options.
Setting them in the script URL
With a plain script tag, the options go on the api.js query
string next to onload and render. hCaptcha’s
loader does the same: its source adds
assethost, imghost, reportapi,
endpoint, host and sentry to the query
and runs each value through encodeURIComponent. Encode URL
values the same way when you write the tag by hand:
<script
src="https://js.hcaptcha.com/1/api.js?render=explicit&onload=onHcaptchaLoad&assethost=https%3A%2F%2Fhcaptcha.your-site.example&imghost=https%3A%2F%2Fhcaptcha.your-site.example&endpoint=https%3A%2F%2Fhcaptcha.your-site.example&reportapi=https%3A%2F%2Fhcaptcha.your-site.example&sentry=false"
async defer></script>
<div id="captcha"></div>
<script>
function onHcaptchaLoad() {
hcaptcha.render("captcha", { sitekey: "f5ab1c2d-7e8f-4a9b-b1c2-d3e4f5a6b7c8" });
}
</script>
Do not rely on hcaptcha.render() for them. The public
render configuration covers the sitekey,
theme, size, callbacks and the other widget options, and none of the host
parameters appear there. Render through the onload callback, as
above: hCaptcha notes that api.js parses its query parameters on
DOM ready, so calling render() straight after the tag can race the
SDK’s setup.
apihost and scriptSource are the two that never go
in the query string, because they decide where api.js itself
comes from. In the loader, apihost replaces the origin in
{apihost}/1/api.js, and scriptSource replaces the
whole URL. With a plain tag you get the same effect by changing the
src.
Setting them through hCaptcha’s SDKs
| Where you configure hCaptcha | How the host options are passed |
|---|---|
Plain <script> tag | Query parameters on the api.js URL, URL-encoded |
@hcaptcha/loader | hCaptchaLoader({ assethost, imghost, endpoint, reportapi, host, sentry, apihost }); it builds the script URL for you |
@hcaptcha/react-hcaptcha | Props on <HCaptcha> with the same names; the component calls the loader |
@hcaptcha/vue-hcaptcha | Props assethost, imghost, endpoint, reportapi, sentry, apiEndpoint |
| Android SDK | HCaptchaConfig fields jsSrc, assethost, imghost, endpoint, reportapi, host, sentry |
import { hCaptchaLoader } from "@hcaptcha/loader";
const FIRST_PARTY = "https://hcaptcha.your-site.example";
await hCaptchaLoader({
apihost: FIRST_PARTY,
assethost: FIRST_PARTY,
imghost: FIRST_PARTY,
endpoint: FIRST_PARTY,
reportapi: FIRST_PARTY,
sentry: false,
});
hcaptcha.render("captcha", { sitekey: "f5ab1c2d-7e8f-4a9b-b1c2-d3e4f5a6b7c8" }); import HCaptcha from "@hcaptcha/react-hcaptcha";
const FIRST_PARTY = "https://hcaptcha.your-site.example";
export function SignupCaptcha({ onVerify }) {
return (
<HCaptcha
sitekey="f5ab1c2d-7e8f-4a9b-b1c2-d3e4f5a6b7c8"
apihost={FIRST_PARTY}
assethost={FIRST_PARTY}
imghost={FIRST_PARTY}
endpoint={FIRST_PARTY}
reportapi={FIRST_PARTY}
sentry={false}
onVerify={onVerify}
/>
);
}
The React component hands these props to the loader, so they end up on the
script URL, and it reads them once, when the script is first requested.
Changing assethost on a mounted component does not reload the
script. Of the host props, only a change to endpoint makes the
component re-render the widget.
CSP for hCaptcha and for a custom host
hCaptcha’s CSP section lists the same two sources for four directives:
Content-Security-Policy:
script-src 'self' https://hcaptcha.com https://*.hcaptcha.com;
frame-src 'self' https://hcaptcha.com https://*.hcaptcha.com;
style-src 'self' https://hcaptcha.com https://*.hcaptcha.com;
connect-src 'self' https://hcaptcha.com https://*.hcaptcha.com
It also asks you not to hard-code a single subdomain such as
newassets.hcaptcha.com, because “asset subdomains used may vary
over time or by region”. Enterprise customers who want hCaptcha’s extra
verification can add unsafe-eval and unsafe-inline
for the same sources.
A CSP only lets the page load from the origins it names, so when the host options point at your own domain, add that origin to the same four directives:
Content-Security-Policy:
script-src 'self' https://hcaptcha.com https://*.hcaptcha.com https://hcaptcha.your-site.example;
frame-src 'self' https://hcaptcha.com https://*.hcaptcha.com https://hcaptcha.your-site.example;
style-src 'self' https://hcaptcha.com https://*.hcaptcha.com https://hcaptcha.your-site.example;
connect-src 'self' https://hcaptcha.com https://*.hcaptcha.com https://hcaptcha.your-site.example
If you load hCaptcha through @hcaptcha/loader, its README asks for
strict-dynamic in your policy, because the loader inserts the
script with appendChild().
Common mistakes
- Taking the host values from user-controlled data. These options decide where the page loads code from, and hCaptcha’s React README warns against passing user-controlled config objects into the component; values from CMS fields, tenant settings or URL parameters should be checked against an explicit allowlist first.
-
Putting a scheme on
host. The other options take full URLs, but the Android SDK documentshostas a bare hostname with nohttp(s)://. - Pinning the CSP to one hCaptcha subdomain. The widget stops loading as soon as hCaptcha serves assets from a different subdomain or region; use the wildcard the docs give.
-
Leaving a URL unencoded in the query string. A raw
https://value insideapi.js?...breaks easily; encode it, or let the loader or an SDK build the URL. -
Running an old Sentry client on the page. With
sentryon, hCaptcha’s loader expects Sentry SDK 8.x or later. An older@sentry/browseron your site can take precedence and throwg.setPropagationContext is not a function. Upgrade it or setsentrytofalse.
const ALLOWED_HOSTS = new Set(["https://hcaptcha.your-site.example"]);
function hostOption(value) {
return ALLOWED_HOSTS.has(value) ? value : undefined;
}
<HCaptcha
sitekey={SITEKEY}
assethost={hostOption(tenant.captchaAssetHost)}
imghost={hostOption(tenant.captchaImgHost)}
/>
When api.js fails to load, @hcaptcha/loader and the
React component raise script-error; with a plain script tag, the
blocked request or CSP report shows in the browser console.
hCaptcha error codes covers
script-error and the rest of the list, and
hCaptcha not working covers the
visitor-side causes. To check a setup without real challenges, use the
test sitekeys.
Tokens for automation and testing
If you are on the other side of the widget, writing an end-to-end test, a QA run or an agent that has to get past hCaptcha, the host options do not change what your code needs: a valid
P1_token submitted ash-captcha-response. The NoneCap hCaptcha solver returns one for the sitekey and page URL you send, and the API reference has the request and response.
Last updated November 2026.
Frequently asked
What is the hCaptcha assethost parameter?
assethost is an optional hCaptcha setting that changes where the widget loads its assets from. hCaptcha’s own SDKs group it with imghost, endpoint, reportapi, host, apihost and scriptSource as the options that “control where hCaptcha assets and API requests are loaded from”, and mark each of them as an Enterprise option.Where are the hCaptcha assethost parameter docs?
hcaptcha-loader, react-hcaptcha, vue-hcaptcha and the Android SDK) plus the Enterprise overview and FAQ on docs.hcaptcha.com. The per-parameter reference is in the Enterprise docs, which the public docs site does not include; the SDK tables point to them with “See enterprise docs”.Do I pass assethost in the script URL or in hcaptcha.render()?
assethost, imghost, endpoint, reportapi, host and sentry to the api.js query string, and the public hcaptcha.render() configuration reference does not list any of them. If you use the React or Vue component, set them as props and the component builds the URL.What CSP does hCaptcha need?
https://hcaptcha.com and https://*.hcaptcha.com for script-src, frame-src, style-src and connect-src, and ask you not to hard-code a single subdomain such as newassets.hcaptcha.com, because asset subdomains change over time and by region. If you serve hCaptcha from your own host, add that origin to the same directives.How do I stop hCaptcha from sending errors to Sentry?
sentry to false: hCaptchaLoader({ sentry: false }), sentry={false} on the React component, or sentry=false on the script URL. hCaptcha’s loader docs say this “will prevent client-side error reports from being sent to us”. It is also the documented fix for the console error g.setPropagationContext is not a function when a site already ships an older Sentry client.