Skip to content
Prompt

tenantweb-test — Cursor Rules

by omar1893

AI Summary

Cursor Rules guide for implementing Better Auth with route/auth protection in Vue 3 + Pinia projects. Developers building authenticated Vue applications benefit from this ready-to-apply configuration template.

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to add the "tenantweb-test — Cursor Rules" prompt rules to my project.
Repository: https://github.com/omar1893/tenantweb-test

Please read the repo to find the rules/prompt file, then:
1. Download it to the correct location (.cursorrules, .windsurfrules, .github/prompts/, or project root — based on the file type)
2. If there's an existing rules file, merge the new rules in rather than overwriting
3. Confirm what was added

Description

Auth and Route protection Implementation Guide

Overview

Better Auth is a modern authentication library that provides a complete authentication solution for web applications. This guide covers the implementation used in this Vue 3 + Pinia project.

Base Configuration

Create a centralized config file for authentication endpoints: `typescript // src/config.ts const config = { api: { baseURL: 'http://localhost:8000', }, auth: { baseURL: 'http://localhost:3000', // Better Auth server URL }, storage: { prefix: 'te-hub', }, }; `

Auth Client Configuration

`typescript // src/lib/auth-client.ts import { magicLinkClient, twoFactorClient } from 'better-auth/client/plugins' import { createAuthClient } from 'better-auth/vue' import { jwtDecode } from 'jwt-decode' import config from '@/config' export const authClient = createAuthClient({ baseURL: config.auth.baseURL, plugins: [ magicLinkClient(), twoFactorClient({ onTwoFactorRedirect() { window.location.href = "/2fa" } }) ], }); `

JWT Token Management

`typescript // JWT caching and validation let jwtToken: string | null = null; let jwtExpiresAt: number | null = null; const getExpiresAt = (jwtToken: string): number => { const decoded = jwtDecode(jwtToken); if (!decoded.exp) { throw new Error("No expires at found"); } return decoded.exp * 1000; } export const getJWT = async (): Promise<string> => { // Development mock token if (import.meta.env.DEV) { return 'MOCK_JWT_TOKEN' } // Return cached token if still valid if (jwtToken && jwtExpiresAt && jwtExpiresAt > Date.now()) { return jwtToken; } // Fetch new token await authClient.getSession({ fetchOptions: { onSuccess: async (ctx) => { jwtToken = ctx.response.headers.get("set-auth-jwt"); if (!jwtToken) { throw new Error("No JWT found"); } } } }); if (!jwtToken) { throw new Error("No JWT found"); } jwtExpiresAt = getExpiresAt(jwtToken); return jwtToken; } `

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted 10mo ago
Stale
AdoptionUnder 100 stars
0 ★ · Niche
DocsMissing or thin
Undocumented

GitHub Signals

Issues0
Updated10mo ago
View on GitHub
No License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Any AI assistant that accepts custom rules or system prompts

Claude
ChatGPT
Cursor
Windsurf
Copilot
+ more