fix: use callback url with route param rather than query
This commit is contained in:
parent
c6f0432d8d
commit
d7a95eab3b
4 changed files with 54 additions and 47 deletions
|
@ -2,8 +2,6 @@ import fs from 'unstorage/drivers/fs'
|
|||
import memory from 'unstorage/drivers/memory'
|
||||
import kv from 'unstorage/drivers/cloudflare-kv-http'
|
||||
|
||||
import { stringifyQuery } from 'ufo'
|
||||
|
||||
import { $fetch } from 'ofetch'
|
||||
import type { Storage } from 'unstorage'
|
||||
|
||||
|
@ -36,7 +34,8 @@ else if (driver === 'memory') {
|
|||
}
|
||||
|
||||
export function getRedirectURI(origin: string, server: string) {
|
||||
return `${origin}/api/${server}/oauth?${stringifyQuery({ origin })}`
|
||||
origin = origin.replace(/\?.*$/, '')
|
||||
return `${origin}/api/${server}/oauth/${encodeURIComponent(origin)}`
|
||||
}
|
||||
|
||||
async function fetchAppInfo(origin: string, server: string) {
|
||||
|
@ -53,8 +52,8 @@ async function fetchAppInfo(origin: string, server: string) {
|
|||
}
|
||||
|
||||
export async function getApp(origin: string, server: string) {
|
||||
const host = origin.replace(/^https?:\/\//, '').replace(/[^\w\d]/g, '-')
|
||||
const key = `servers:v2:${server}:${host}.json`.toLowerCase()
|
||||
const host = origin.replace(/^https?:\/\//, '').replace(/[^\w\d]/g, '-').replace(/\?.*$/, '')
|
||||
const key = `servers:v3:${server}:${host}.json`.toLowerCase()
|
||||
|
||||
try {
|
||||
if (await storage.hasItem(key))
|
||||
|
@ -69,13 +68,13 @@ export async function getApp(origin: string, server: string) {
|
|||
}
|
||||
|
||||
export async function deleteApp(server: string) {
|
||||
const keys = (await storage.getKeys(`servers:v2:${server}:`))
|
||||
const keys = (await storage.getKeys(`servers:v3:${server}:`))
|
||||
for (const key of keys)
|
||||
await storage.removeItem(key)
|
||||
}
|
||||
|
||||
export async function listServers() {
|
||||
const keys = await storage.getKeys('servers:v2:')
|
||||
const keys = await storage.getKeys('servers:v3:')
|
||||
const servers = new Set<string>()
|
||||
for await (const key of keys) {
|
||||
const id = key.split(':')[2]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue