Going to production
An app that signs in locally needs a production instance before it signs in on your domain. This page takes the app from the quickstart to that instance in three steps, and ends on every error a misconfigured instance shows, with its exact text, its cause, and its fix.
Your local instance serves http://localhost at any port, so it never needed an origin from you. A production instance serves only the HTTPS origins you list, and sign-in fails on any other origin until you list it.
Create the production instance
Section titled âCreate the production instanceâCreate a new instance in the Keyhaw dashboard for production. Keep your local instance for development, so the two never share users, passkeys, or keys.
An instance with no users can move to your domain in place instead. Open the instance you used locally and edit its RP ID and allowed origins as the next step describes. Do this only when nobody has signed up, since the edit orphans every passkey made on localhost.
Set the RP ID and allowed origins
Section titled âSet the RP ID and allowed originsâOpen the instance in the dashboard, go to its edit page, and fill in two fields.
- The RP ID is the domain your passkeys belong to, such as
example.com. It must be a lowercase domain with at least one dot, with no scheme, port, or path. - The allowed origins are the HTTPS origins your app serves from, separated by commas, such as
https://example.com,https://app.example.com. An origin is a scheme and a host, with no path and no trailing slash. A leading*.matches every subdomain, as inhttps://*.example.com.
The RP ID has to cover every allowed origin. example.com covers https://example.com and any host under it, and does not cover https://other.test.
Replace the localhost origin instead of adding to it. The form refuses a list that keeps http://localhost:* beside an HTTPS origin, and it refuses any RP ID but localhost on a list that holds localhost alone.
A passkey made on localhost does not sign in on your domain, because a passkey belongs to the domain it was created on. Users you created while developing register again on the production instance, and a domain RP ID never accepts localhost. Production carries no localhost exemption to remember to remove, which is why development gets an instance of its own.
Swap in the production keys
Section titled âSwap in the production keysâCopy the production instanceâs keys from its page in the dashboard into your production environment, under the variable names the quickstart uses. The dashboard shows the secret key once, when you create the instance or rotate the key, so copy it then.
# production environmentVITE_KEYHAW_PUBLISHABLE_KEY=pk_...A Vite single-page app builds the publishable key into the page, so set the variable in the environment that runs vite build. If your Vite build includes a server, set KEYHAW_SECRET_KEY=sk_... where that server runs as well.
# production environmentNEXT_PUBLIC_KEYHAW_PUBLISHABLE_KEY=pk_...KEYHAW_SECRET_KEY=sk_...Next.js reads NEXT_PUBLIC_ variables at build time, so set the publishable key in the environment that runs next build.
# production environmentPUBLIC_KEYHAW_PUBLISHABLE_KEY=pk_...KEYHAW_SECRET_KEY=sk_...Leave the local keys in your local .env, and keep the production secret key out of version control.
Deploy, open your production domain, and sign in. A userâs first visit registers a passkey, and the next sign-in uses it with no code.
Keyhaw limits new accounts on each instance and sign-in attempts from each address. A limit refuses only the request that crosses it, so a returning user who is under every limit signs in as usual.
On an instance with a domain RP ID, four limits apply.
- The registration limit is 500 new accounts an hour for the whole instance. It rises once the instance has more than 5,000 retained users, the users who signed in or renewed a session in the last 30 days at least a day after their account was created, to a tenth of that count rounded up. It counts each request that opens an account, which is a
register/beginwith no session. - The client limit is half the registration limit, rounded down, so 250 an hour at the floor. It holds one address to that share of the instanceâs new accounts, so one address cannot use up the registration limit and refuse everyone else.
- The new-account filter is 300
register/beginrequests a minute from one address. - The sign-in filter is 600
authenticate/beginrequests a minute from one address, on every instance. A page with a passkey input opens one of these when it loads and renews it every 45 seconds.
A local instance, whose RP ID is localhost, has its own numbers, and they never grow or change with a lift. Its new-account filter is 120 a minute, and its registration limit and client limit are both 200 an hour, since all its traffic comes from one machine. It also counts completed sign-ins and registrations, not begins, and allows 250 of them an hour.
A refused request answers with status 429 and this body.
{ "error": "Too many attempts. Try again in a few minutes.", "code": "rate_limited", "retryAfter": 60}The Retry-After header holds the same number of whole seconds as retryAfter, from 1 to 3,600. A filter refusal always says 60, and the other limits say how many seconds until a place frees. A page that cannot read the header across origins still has the body. <SignIn /> shows âToo many attempts. Try again in a few minutes.â on the status line under the button for this response, and it does not name the limit.
A refusal by the registration limit stops new sign-ups on the instance until the limit frees, and returning users still sign in. A launch that expects more new accounts than the registration limit allows asks Keyhaw for a lift before it starts. A lift raises the registration limit and the client limit for a set number of days, and only Keyhaw can set one, so ask before you launch, and say how many new accounts you expect each hour.
Errors you can see
Section titled âErrors you can seeâA misconfigured instance fails in two places. The dashboardâs edit form refuses a configuration it cannot serve, and the tenant API refuses a sign-in request from an origin or instance it cannot answer.
Edit form errors
Section titled âEdit form errorsâThe form joins every problem it finds with ; and shows them above the Save button. Text in angle brackets stands for the value you entered.
| Message | Cause | Fix |
|---|---|---|
an RP ID is required |
The RP ID field is empty. | Enter localhost or your domain. |
RP ID "<rp id>" is local; use "localhost" |
The RP ID is a local host name other than localhost, such as foo.localhost or an IP address. |
Use localhost for local development, or your domain. |
RP ID "<rp id>" is not a registrable domain |
The RP ID has no dot, such as example. |
Enter a domain such as example.com. |
RP ID "<rp id>" must be a lowercase hostname |
The RP ID has uppercase letters, or characters other than letters, digits, dots, and hyphens, such as a scheme or a port. | Enter the bare lowercase domain, as in example.com. |
at least one allowed origin is required |
The allowed origins field is empty. | List at least one origin. |
"<origin>" is not allowed: a wildcard may only be the leftmost label, as in https://*.example.com, or the port of http://localhost:* |
A * appears anywhere but the leftmost label of an HTTPS origin or the port of http://localhost:*. |
Write https://*.example.com for subdomains. |
"<origin>" is not a valid https origin |
The entry is not a URL, or a non-local entry uses http. |
Write the origin with https://. |
"<origin>" is not a valid origin |
The entry is not an origin of any kind. | Write an origin such as https://example.com. |
"<origin>" is not a bare origin; expected <origin> |
The entry carries a path, a trailing slash, a query, or a default port. | Use the origin the message names. |
"<origin>" is not allowed: the only local origin is http://localhost, as in http://localhost:* or http://localhost:5173 |
The entry is https://localhost, a subdomain of localhost, or an IP address. |
Use http://localhost:* or http://localhost:<port> under RP ID localhost. |
"<origin>" wildcards too broad a domain |
A wildcard sits over a bare top-level domain, as in https://*.com. |
Put the wildcard over your own domain, as in https://*.example.com. |
the allowed origins mix localhost with HTTPS origins, and no RP ID covers both; list localhost on one instance and your HTTPS origins on another |
The list holds http://localhost beside an HTTPS origin. |
Replace the localhost origin, and keep localhost on your local instance. |
RP ID "<rp id>" does not cover the origin "<origin>" |
The originâs host is neither the RP ID nor a subdomain of it. A domain RP ID with a localhost origin lands here. | Set an RP ID that is the originâs domain or a parent of it. |
Sign-in refusals
Section titled âSign-in refusalsâThe tenant API answers a request it cannot serve with a 403 that carries one of four codes. An app with a server proxies the request through that server, which prints the matching warning to its output once per code and process. Look for it in the output of your production server. A page that calls its instance directly, such as a Vite single-page app, shows a browser console error instead, because the browser blocks a refused response, and <SignIn /> shows âThat didnât work. Try again.â on the status line under the button once a clickâs request fails.
Each warning begins keyhaw refused a sign-in request (<code>). and <SignIn /> on an app with a server shows the same âThat didnât work. Try again.â under the button.
| Code and response error | Warning | Cause and fix |
|---|---|---|
instance-not-found, âInvalid tenantâ |
No instance answers to the publishable key this server uses. Copy the key from the Keyhaw dashboard into KEYHAW_PUBLISHABLE_KEY. |
The key is missing, mistyped, or from a deleted instance. Copy the production instanceâs publishable key into the variable from the previous step. The warning names the unprefixed KEYHAW_PUBLISHABLE_KEY, which an adapter reads when the prefixed variable is unset. |
instance-not-serving, âTenant is not configured for passkeysâ |
The instance is not set up to serve sign-in yet. Finish its setup on the Keyhaw dashboard, where it needs an RP ID and at least one allowed origin. |
The instance has no RP ID or no allowed origin, or its configuration fails the checks above. Edit it until the form saves. |
origin-missing, âOrigin header is requiredâ |
The request reached the instance with no Origin header. Send it from a page in a browser, which adds one. |
A script or curl called the instance with no Origin header. Call it from your page, or send the header. |
origin-not-allowed, âOrigin not allowed for this tenantâ |
The instance does not allow the origin <origin>. Add it to the instance's allowed origins on the Keyhaw dashboard. When you run locally, use the publishable key of an instance whose RP ID is localhost, which allows any localhost port. |
The pageâs origin is not on the allowed list. This is the error a launch hits first. Add the exact origin the warning names, such as https://www.example.com, which differs from https://example.com. Locally, use the local instanceâs key. |
When origin-not-allowed appears on your production domain, compare the origin the warning names with the allowed origins on the instanceâs page. A different scheme, a www. prefix, or a port is a different origin.