BA
Better Authโ€ข5w ago
colin

How to debug addPasskey not working in Production (Vercel)?

Having configured the passkey plugin, I can add a passkey locally/development but not in production (Vercel). I'm using a simple button in NextJS to trigger adding a passkey:
const { data, error } = await authClient.passkey.addPasskey();
const { data, error } = await authClient.passkey.addPasskey();
Which locally, prompts my browser (Firefox or Chrome) to a add a passkey. However, in production on Vercel, I see the GET request to:
https://api.mysite.com/v1/auth/passkey/generate-register-options 200 OK
https://api.mysite.com/v1/auth/passkey/generate-register-options 200 OK
And the response looks ok (I think?):
{
"challenge": "4ShVg5WW5XJRuw_2RLFzfcDuzOjt_vix5ZwXUR761qQ",
"rp": {
"name": "My App",
"id": "api.mysite.com"
},
"user": {
"id": "aWt4OWt0aHMzbXlreXZpMXc5Z3FrdHp4eGpxZW92cTA",
"name": "[email protected]",
"displayName": ""
},
"pubKeyCredParams": [
{
"alg": -8,
"type": "public-key"
},
{
"alg": -7,
"type": "public-key"
},
{
"alg": -257,
"type": "public-key"
}
],
"timeout": 60000,
"attestation": "none",
"excludeCredentials": [],
"authenticatorSelection": {
"residentKey": "preferred",
"userVerification": "preferred",
"requireResidentKey": false
},
"extensions": {
"credProps": true
},
"hints": []
}
{
"challenge": "4ShVg5WW5XJRuw_2RLFzfcDuzOjt_vix5ZwXUR761qQ",
"rp": {
"name": "My App",
"id": "api.mysite.com"
},
"user": {
"id": "aWt4OWt0aHMzbXlreXZpMXc5Z3FrdHp4eGpxZW92cTA",
"name": "[email protected]",
"displayName": ""
},
"pubKeyCredParams": [
{
"alg": -8,
"type": "public-key"
},
{
"alg": -7,
"type": "public-key"
},
{
"alg": -257,
"type": "public-key"
}
],
"timeout": 60000,
"attestation": "none",
"excludeCredentials": [],
"authenticatorSelection": {
"residentKey": "preferred",
"userVerification": "preferred",
"requireResidentKey": false
},
"extensions": {
"credProps": true
},
"hints": []
}
But the browser prompt to add the passkey doesn't trigger/appear. And there's no subsequent /passkey/verify-registration POST request as there is locally. I can't figure out what the issue could be as I'm not seeing any errors in my browser or Vercel's logs. Any help on where to start debugging this would be appreciated. ๐Ÿ™
Solution:
I managed to resolve this. I had the value for rpID wrongly configured. ๐Ÿคฆ It was set to api.mysite.com rather than mysite.com. A [Fido2Client] Error in the Chrome console alerted me to the issue....
Jump to solution
10 Replies
Ping
Pingโ€ข5w ago
Hey, I've never used the Passkey plugin, but I can still try and help. Looking through the docs, I noticed an origin option. Did you add this?
No description
colin
colinOPโ€ข5w ago
Yep. I've tried setting that to my NextJS domain, but unfortunately it didn't work. It's so weird not getting any errors at all. btw, Thanks for replying. Just saw in the logs: GET /.well-known/webauthn 404
Ping
Pingโ€ข5w ago
Hmm. I assume it's meant to hit /api/auth/.well-known/webauthn? Not super sure ๐Ÿ˜…
colin
colinOPโ€ข5w ago
yep. my assumption too. I'm going to check if that end point is hit on my local (working) env
Ping
Pingโ€ข5w ago
Yeah
colin
colinOPโ€ข5w ago
just found this thread on GitHub: WebAuthn works locally, but not in production - https://github.com/MasterKale/SimpleWebAuthn/issues/345. Out now, so gonna run through it a bit later.
GitHub
Issues ยท MasterKale/SimpleWebAuthn
WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers, Node, Deno, and more. - Issues ยท MasterKale/SimpleWebAuthn
colin
colinOPโ€ข5w ago
Will update later if I find anything. ๐Ÿ‘
Ping
Pingโ€ข5w ago
Sure, i'll try my best to help
colin
colinOPโ€ข4w ago
Thank you. ๐Ÿ˜Š Couldn't figure out what the issue was. Think i'll post on the Vercel repo. It may be something specific to their platform Thanks for you help
Solution
colin
colinโ€ข4w ago
I managed to resolve this. I had the value for rpID wrongly configured. ๐Ÿคฆ It was set to api.mysite.com rather than mysite.com. A [Fido2Client] Error in the Chrome console alerted me to the issue. Thanks again for your help. ๐Ÿ‘

Did you find this page helpful?