unable to verify the first certificate - UNABLE_TO_VERIFY_LEAF_SIGNATURE Nextjs Middleware - auth v5
Unanswered
Giant panda posted this in #help-forum
Giant pandaOP
I'm getting the following error, trying to access a subdomain (the
employers subdomain) in my middleware. It didn't happen before I started migrating to auth v5Failed to proxy https://localhost.com:3001/employers Error: unable to verify the first certificate
at TLSSocket.onConnectSecure (node:_tls_wrap:1659:34)
at TLSSocket.emit (node:events:514:28)
at TLSSocket._finishInit (node:_tls_wrap:1070:8)
at ssl.onhandshakedone (node:_tls_wrap:856:12)
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}1 Reply
Giant pandaOP
My middleware looks like this:
const hostname = req.headers
.get('host')!
.replace('.localhost.com:3001', `.${webEnv.NEXT_PUBLIC_ROOT_DOMAIN}`)
const subdomain = hostname.replace(`.verk.so`, '')
console.log(subdomain)
if(subdomain == 'employers') {
const url = req.nextUrl
const path = url.pathname
url.pathname = `/employers${path}`
return NextResponse.rewrite(new URL(url))
}