mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 09:48:27 +00:00
* Feat: add mcp oauth2.1 support * Fix: integration mcp is not loading * Feat: add slack integration --------- Co-authored-by: Manoj K <saimanoj58@gmail.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { callbackHandler } from "~/services/oauth/oauth.server";
|
|
import type { CallbackParams } from "~/services/oauth/oauth-utils.server";
|
|
import { type LoaderFunctionArgs } from "@remix-run/node";
|
|
|
|
// This route handles the OAuth callback, similar to the NestJS controller
|
|
export async function loader({ request }: LoaderFunctionArgs) {
|
|
// Handle CORS preflight
|
|
if (request.method.toUpperCase() === "OPTIONS") {
|
|
return new Response(null, {
|
|
status: 200,
|
|
headers: {
|
|
"Access-Control-Allow-Origin": "*",
|
|
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
"Access-Control-Allow-Headers": "Content-Type",
|
|
},
|
|
});
|
|
}
|
|
|
|
// Only allow GET requests
|
|
if (request.method.toUpperCase() !== "GET") {
|
|
return new Response("Method Not Allowed", {
|
|
status: 405,
|
|
headers: { Allow: "GET" }
|
|
});
|
|
}
|
|
|
|
try {
|
|
const url = new URL(request.url);
|
|
const params: CallbackParams = {};
|
|
for (const [key, value] of url.searchParams.entries()) {
|
|
params[key] = value;
|
|
}
|
|
return await callbackHandler(params);
|
|
} catch (error) {
|
|
console.error("OAuth callback error:", error);
|
|
return new Response("Internal Server Error", { status: 500 });
|
|
}
|
|
} |