🐛 Fix well known error

This commit is contained in:
LittleSheep 2025-03-22 23:43:15 +08:00
parent 0276272b42
commit 4e0ce9118d
2 changed files with 6 additions and 7 deletions

View File

@ -1,10 +1,9 @@
import { defineEventHandler } from 'h3'
import { solarFetch } from '~/utils/request'
export default defineEventHandler(async () => {
const solarNetworkApi = 'https://api.sn.solsynth.dev'
const config = useRuntimeConfig();
const resp = await solarFetch(`${solarNetworkApi}/cgi/id/well-known/jwks`)
const resp = await fetch(`${config.public.solarNetworkApi}/cgi/id/well-known/jwks`)
return await resp.json()
})

View File

@ -2,10 +2,10 @@ import { defineEventHandler } from 'h3'
import { solarFetch } from '~/utils/request'
export default defineEventHandler(async () => {
const siteUrl = 'https://solsynth.dev'
const solarNetworkApi = 'https://api.sn.solsynth.dev'
const config = useRuntimeConfig();
const siteUrl = config.app.baseURL
const resp = await solarFetch(`${solarNetworkApi}/cgi/id/well-known/openid-configuration`)
const resp = await solarFetch(`${config.public.solarNetworkApi}/cgi/id/well-known/openid-configuration`)
const out: Record<string, any> = await resp.json()
out['authorization_endpoint'] = `${siteUrl}/auth/authorize`
@ -13,7 +13,7 @@ export default defineEventHandler(async () => {
for (const [k, v] of Object.entries(out)) {
if (typeof v === 'string' && v.startsWith('https://id.solsynth.dev/api')) {
out[k] = v.replace('https://id.solsynth.dev/api', `${solarNetworkApi}/cgi/id`)
out[k] = v.replace('https://id.solsynth.dev/api', `${config.public.solarNetworkApi}/cgi/id`)
}
}