mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 04:19:32 +00:00
docs: use createFileRoute on TanStack API (#4885)
This commit is contained in:
@@ -13,16 +13,20 @@ We need to mount the handler to a TanStack API endpoint/Server Route.
|
|||||||
Create a new file: `/src/routes/api/auth/$.ts`
|
Create a new file: `/src/routes/api/auth/$.ts`
|
||||||
|
|
||||||
```ts title="src/routes/api/auth/$.ts"
|
```ts title="src/routes/api/auth/$.ts"
|
||||||
import { auth } from '@/lib/auth' // import your auth instance
|
import { auth } from '@/lib/auth'
|
||||||
import { createServerFileRoute } from '@tanstack/react-start/server'
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
export const ServerRoute = createServerFileRoute('/api/auth/$').methods({
|
export const Route = createFileRoute('/api/auth/$')({
|
||||||
|
server: {
|
||||||
|
handlers: {
|
||||||
GET: ({ request }) => {
|
GET: ({ request }) => {
|
||||||
return auth.handler(request)
|
return auth.handler(request)
|
||||||
},
|
},
|
||||||
POST: ({ request }) => {
|
POST: ({ request }) => {
|
||||||
return auth.handler(request)
|
return auth.handler(request)
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user