mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
fix: Improve OAuth callback URL handling in authentication flow
This commit is contained in:
parent
f40979b4ad
commit
c176362949
@ -14,7 +14,6 @@ export async function POST(req: Request) {
|
||||
const nonce = WordArray.random(16).toString();
|
||||
let return_url = `${hostUrl}/authorize`;
|
||||
|
||||
// 尝试从请求中获取 return_url
|
||||
try {
|
||||
const body = await req.json();
|
||||
if (body.return_url) {
|
||||
|
@ -25,9 +25,11 @@ export function UserAuthForm({
|
||||
try {
|
||||
const body: Record<string, any> = {};
|
||||
const callbackUrl = searchParams?.get("callbackUrl");
|
||||
if (callbackUrl) {
|
||||
const decodedUrl = decodeURIComponent(callbackUrl);
|
||||
body.return_url = decodedUrl;
|
||||
|
||||
// 如果是 OAuth 回调,则提取原始的 /oauth/authorize 部分
|
||||
if (callbackUrl?.includes("/oauth/authorize")) {
|
||||
const url = new URL(callbackUrl);
|
||||
body.return_url = `${window.location.origin}${url.pathname}${url.search}`;
|
||||
}
|
||||
|
||||
const response = await fetch("/api/auth/q58", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user