Skip to content

Commit 84612bf

Browse files
authored
feat: Add OAuthProxy (#18)
1 parent 7053bea commit 84612bf

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
"tslib": "^2.8.1",
4141
"typescript": "^5.9.3",
4242
"vite": "^7.3.0",
43+
"vite-plugin-devtools-json": "^1.0.0",
4344
"vitest": "^4.0.16"
45+
},
46+
"pnpm": {
47+
"onlyBuiltDependencies": [
48+
"esbuild"
49+
]
4450
}
45-
}
51+
}

pnpm-lock.yaml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/auth.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getRequestEvent } from '$app/server'
22
import { PRIVATE_BETTER_AUTH_SECRET, PRIVATE_TRAKT_CLIENT_ID, PRIVATE_TRAKT_CLIENT_SECRET } from '$env/static/private'
33
import { PUBLIC_BETTER_AUTH_URL } from '$env/static/public'
44
import { betterAuth } from 'better-auth'
5-
import { customSession, genericOAuth } from 'better-auth/plugins'
5+
import { customSession, genericOAuth, oAuthProxy } from 'better-auth/plugins'
66
import { sveltekitCookies } from 'better-auth/svelte-kit'
77

88
interface TraktUser {
@@ -22,6 +22,10 @@ interface TraktUser {
2222
export const auth = betterAuth({
2323
secret: PRIVATE_BETTER_AUTH_SECRET,
2424
baseURL: PUBLIC_BETTER_AUTH_URL,
25+
trustedOrigins: [
26+
PUBLIC_BETTER_AUTH_URL,
27+
...(process.env.NETLIFY_URL ? [process.env.NETLIFY_URL] : []),
28+
],
2529
// Stateless mode - no database required
2630
// This will automatically enable JWT-based sessions in cookies
2731
session: {
@@ -83,5 +87,8 @@ export const auth = betterAuth({
8387
}
8488
}),
8589
sveltekitCookies(getRequestEvent),
90+
oAuthProxy({
91+
productionURL: PUBLIC_BETTER_AUTH_URL,
92+
})
8693
],
8794
})

vite.config.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { enhancedImages } from '@sveltejs/enhanced-img'
2-
import { sveltekit } from '@sveltejs/kit/vite'
3-
import { defineConfig } from 'vitest/config'
1+
import devtoolsJson from 'vite-plugin-devtools-json';
2+
import { enhancedImages } from '@sveltejs/enhanced-img';
3+
import { sveltekit } from '@sveltejs/kit/vite';
4+
import { defineConfig } from 'vitest/config';
45

56
export default defineConfig({
6-
plugins: [
7-
enhancedImages(),
8-
sveltekit(),
9-
],
7+
plugins: [enhancedImages(), sveltekit(), devtoolsJson()],
8+
109
test: {
1110
include: ['src/**/__tests__/*.ts'],
12-
coverage: {
13-
include: ['src/lib/utils/*.ts', 'src/lib/actions.ts'],
14-
},
15-
},
16-
})
11+
coverage: { include: ['src/lib/utils/*.ts', 'src/lib/actions.ts'] }
12+
}
13+
});

0 commit comments

Comments
 (0)