File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3636 " vite-plugin-pwa" ,
3737 " vue-router"
3838 ],
39- "ignoreUnresolved" : [" #components" ]
39+ "ignoreUnresolved" : [" #components" , " #oauth/config " ]
4040 },
4141 "cli" : {
4242 "project" : [" src/**/*.ts" ]
Original file line number Diff line number Diff line change 1- import { defineNuxtModule , useNuxt } from 'nuxt/kit'
1+ import { defineNuxtModule , useNuxt , addServerTemplate } from 'nuxt/kit'
22import { join } from 'node:path'
33import { appendFileSync , existsSync , readFileSync } from 'node:fs'
44import { randomUUID } from 'node:crypto'
@@ -9,6 +9,26 @@ export default defineNuxtModule({
99 } ,
1010 setup ( ) {
1111 const nuxt = useNuxt ( )
12+
13+ const env = process . env . NUXT_ENV_VERCEL_ENV
14+ const previewUrl = process . env . NUXT_ENV_VERCEL_URL
15+ const prodUrl = process . env . NUXT_ENV_VERCEL_PROJECT_PRODUCTION_URL
16+
17+ let clientUri : string
18+ if ( env === 'preview' && previewUrl ) {
19+ clientUri = `https://${ previewUrl } `
20+ } else if ( env === 'production' && prodUrl ) {
21+ clientUri = `https://${ prodUrl } `
22+ } else {
23+ clientUri = 'http://127.0.0.1:3000'
24+ }
25+
26+ // bake it into a virtual file
27+ addServerTemplate ( {
28+ filename : '#oauth/config' ,
29+ getContents : ( ) => `export const clientUri = ${ JSON . stringify ( clientUri ) } ;` ,
30+ } )
31+
1232 if ( nuxt . options . _prepare || process . env . NUXT_SESSION_PASSWORD ) {
1333 return
1434 }
Original file line number Diff line number Diff line change @@ -6,14 +6,15 @@ import { getOAuthLock } from '#server/utils/atproto/lock'
66import { useOAuthStorage } from '#server/utils/atproto/storage'
77import { UNSET_NUXT_SESSION_PASSWORD } from '#shared/utils/constants'
88import { OAuthMetadataSchema } from '#shared/schemas/oauth'
9+ // @ts -expect-error virtual file from oauth module
10+ import { clientUri } from '#oauth/config'
911// TODO: limit scope as features gets added. atproto just allows login so no scary login screen till we have scopes
1012export const scope = 'atproto'
1113
1214export function getOauthClientMetadata ( ) {
1315 const dev = import . meta. dev
1416
15- // on dev, match in nuxt.config.ts devServer: { host: "127.0.0.1" }
16- const client_uri = dev ? `http://127.0.0.1:3000` : 'https://npmx.dev'
17+ const client_uri = clientUri
1718 const redirect_uri = `${ client_uri } /api/auth/atproto`
1819
1920 const client_id = dev
You can’t perform that action at this time.
0 commit comments