🐛 Fix well known error
This commit is contained in:
parent
0276272b42
commit
4e0ce9118d
@ -1,10 +1,9 @@
|
|||||||
import { defineEventHandler } from 'h3'
|
import { defineEventHandler } from 'h3'
|
||||||
import { solarFetch } from '~/utils/request'
|
|
||||||
|
|
||||||
export default defineEventHandler(async () => {
|
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()
|
return await resp.json()
|
||||||
})
|
})
|
@ -2,10 +2,10 @@ import { defineEventHandler } from 'h3'
|
|||||||
import { solarFetch } from '~/utils/request'
|
import { solarFetch } from '~/utils/request'
|
||||||
|
|
||||||
export default defineEventHandler(async () => {
|
export default defineEventHandler(async () => {
|
||||||
const siteUrl = 'https://solsynth.dev'
|
const config = useRuntimeConfig();
|
||||||
const solarNetworkApi = 'https://api.sn.solsynth.dev'
|
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()
|
const out: Record<string, any> = await resp.json()
|
||||||
|
|
||||||
out['authorization_endpoint'] = `${siteUrl}/auth/authorize`
|
out['authorization_endpoint'] = `${siteUrl}/auth/authorize`
|
||||||
@ -13,7 +13,7 @@ export default defineEventHandler(async () => {
|
|||||||
|
|
||||||
for (const [k, v] of Object.entries(out)) {
|
for (const [k, v] of Object.entries(out)) {
|
||||||
if (typeof v === 'string' && v.startsWith('https://id.solsynth.dev/api')) {
|
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`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user