- 
                Notifications
    You must be signed in to change notification settings 
- Fork 403
          chore(nuxt): Expose event.context.auth() as function
          #5513
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 🦋 Changeset detectedLatest commit: ffb0210 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
 Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR | 
| The latest updates on your projects. Learn more about Vercel for Git ↗︎ 
 | 
8e80255    to
    580016d      
    Compare
  
    580016d    to
    42f68bc      
    Compare
  
    13fbb72    to
    a5a0837      
    Compare
  
    a5a0837    to
    04d793c      
    Compare
  
    | !snapshot | 
| Hey @LauraBeatris - the snapshot version command generated the following package versions: 
 Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.0.17-snapshot.v20250402165855 --save-exact
 npm i @clerk/astro@2.4.6-snapshot.v20250402165855 --save-exact
 npm i @clerk/backend@1.26.0-snapshot.v20250402165855 --save-exact
 npm i @clerk/chrome-extension@2.2.24-snapshot.v20250402165855 --save-exact
 npm i @clerk/clerk-js@5.59.0-snapshot.v20250402165855 --save-exact
 npm i @clerk/elements@0.23.9-snapshot.v20250402165855 --save-exact
 npm i @clerk/clerk-expo@2.9.7-snapshot.v20250402165855 --save-exact
 npm i @clerk/expo-passkeys@0.2.1-snapshot.v20250402165855 --save-exact
 npm i @clerk/express@1.3.60-snapshot.v20250402165855 --save-exact
 npm i @clerk/fastify@2.1.33-snapshot.v20250402165855 --save-exact
 npm i @clerk/localizations@3.13.5-snapshot.v20250402165855 --save-exact
 npm i @clerk/nextjs@6.12.13-snapshot.v20250402165855 --save-exact
 npm i @clerk/nuxt@1.5.0-snapshot.v20250402165855 --save-exact
 npm i @clerk/clerk-react@5.25.6-snapshot.v20250402165855 --save-exact
 npm i @clerk/react-router@1.1.12-snapshot.v20250402165855 --save-exact
 npm i @clerk/remix@4.5.12-snapshot.v20250402165855 --save-exact
 npm i @clerk/shared@3.3.0-snapshot.v20250402165855 --save-exact
 npm i @clerk/tanstack-react-start@0.12.3-snapshot.v20250402165855 --save-exact
 npm i @clerk/testing@1.4.34-snapshot.v20250402165855 --save-exact
 npm i @clerk/themes@2.2.27-snapshot.v20250402165855 --save-exact
 npm i @clerk/types@4.50.2-snapshot.v20250402165855 --save-exact
 npm i @clerk/vue@1.4.6-snapshot.v20250402165855 --save-exact | 
| !snapshot | 
| Hey @LauraBeatris - the snapshot version command generated the following package versions: 
 Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.0.17-snapshot.v20250402171054 --save-exact
 npm i @clerk/astro@2.4.6-snapshot.v20250402171054 --save-exact
 npm i @clerk/backend@1.26.0-snapshot.v20250402171054 --save-exact
 npm i @clerk/chrome-extension@2.2.24-snapshot.v20250402171054 --save-exact
 npm i @clerk/clerk-js@5.59.0-snapshot.v20250402171054 --save-exact
 npm i @clerk/elements@0.23.9-snapshot.v20250402171054 --save-exact
 npm i @clerk/clerk-expo@2.9.7-snapshot.v20250402171054 --save-exact
 npm i @clerk/expo-passkeys@0.2.1-snapshot.v20250402171054 --save-exact
 npm i @clerk/express@1.3.60-snapshot.v20250402171054 --save-exact
 npm i @clerk/fastify@2.1.33-snapshot.v20250402171054 --save-exact
 npm i @clerk/localizations@3.13.5-snapshot.v20250402171054 --save-exact
 npm i @clerk/nextjs@6.12.13-snapshot.v20250402171054 --save-exact
 npm i @clerk/nuxt@1.5.0-snapshot.v20250402171054 --save-exact
 npm i @clerk/clerk-react@5.25.6-snapshot.v20250402171054 --save-exact
 npm i @clerk/react-router@1.1.12-snapshot.v20250402171054 --save-exact
 npm i @clerk/remix@4.5.12-snapshot.v20250402171054 --save-exact
 npm i @clerk/shared@3.3.0-snapshot.v20250402171054 --save-exact
 npm i @clerk/tanstack-react-start@0.12.3-snapshot.v20250402171054 --save-exact
 npm i @clerk/testing@1.4.34-snapshot.v20250402171054 --save-exact
 npm i @clerk/themes@2.2.27-snapshot.v20250402171054 --save-exact
 npm i @clerk/types@4.50.2-snapshot.v20250402171054 --save-exact
 npm i @clerk/vue@1.4.6-snapshot.v20250402171054 --save-exact | 
| !snapshot | 
| Hey @LauraBeatris - the snapshot version command generated the following package versions: 
 Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.0.17-snapshot.v20250402174132 --save-exact
 npm i @clerk/astro@2.4.6-snapshot.v20250402174132 --save-exact
 npm i @clerk/backend@1.26.0-snapshot.v20250402174132 --save-exact
 npm i @clerk/chrome-extension@2.2.24-snapshot.v20250402174132 --save-exact
 npm i @clerk/clerk-js@5.59.0-snapshot.v20250402174132 --save-exact
 npm i @clerk/elements@0.23.9-snapshot.v20250402174132 --save-exact
 npm i @clerk/clerk-expo@2.9.7-snapshot.v20250402174132 --save-exact
 npm i @clerk/expo-passkeys@0.2.1-snapshot.v20250402174132 --save-exact
 npm i @clerk/express@1.3.60-snapshot.v20250402174132 --save-exact
 npm i @clerk/fastify@2.1.33-snapshot.v20250402174132 --save-exact
 npm i @clerk/localizations@3.13.5-snapshot.v20250402174132 --save-exact
 npm i @clerk/nextjs@6.12.13-snapshot.v20250402174132 --save-exact
 npm i @clerk/nuxt@1.5.0-snapshot.v20250402174132 --save-exact
 npm i @clerk/clerk-react@5.25.6-snapshot.v20250402174132 --save-exact
 npm i @clerk/react-router@1.1.12-snapshot.v20250402174132 --save-exact
 npm i @clerk/remix@4.5.12-snapshot.v20250402174132 --save-exact
 npm i @clerk/shared@3.3.0-snapshot.v20250402174132 --save-exact
 npm i @clerk/tanstack-react-start@0.12.3-snapshot.v20250402174132 --save-exact
 npm i @clerk/testing@1.4.34-snapshot.v20250402174132 --save-exact
 npm i @clerk/themes@2.2.27-snapshot.v20250402174132 --save-exact
 npm i @clerk/types@4.50.2-snapshot.v20250402174132 --save-exact
 npm i @clerk/vue@1.4.6-snapshot.v20250402174132 --save-exact | 
54fc6b1    to
    c20a798      
    Compare
  
    c20a798    to
    4a3cb7d      
    Compare
  
    4a3cb7d    to
    d19689a      
    Compare
  
    d19689a    to
    8c5ebcc      
    Compare
  
    |  | ||
| const authObject = requestState.toAuth(); | ||
| event.context.auth = authObject; | ||
| const authHandler = () => authObject; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning to raise another PR after shipping this one, which it'll introduce some parameters to this authHandler
That's the whole reason we're doing this change as well, so having a function allow to perform custom logic against the auth object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the same code example we have in the description here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great here!
Description
Resolves ORGS-622
Deprecate
event.context.authin favor ofevent.context.auth():export default clerkMiddleware((event) => { + const { userId } = event.context.auth() - const { userId } = event.context.auth const isAdminRoute = event.path.startsWith('/api/admin') if (!userId && isAdminRoute) { throw createError({ statusCode: 401, statusMessage: 'Unauthorized: User not signed in', }) } })This change is needed for an upcoming feature in which options are passed to auth:
auth({ treatPendingAsSignedOn })Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change