core/apps/webapp/app/routes/api.v1.oauth.callback.tsx
Harshith Mullapudi b380f2657f
Feat: add mcp oauth2.1 support (#30)
* Feat: add mcp oauth2.1 support

* Fix: integration mcp is not loading

* Feat: add slack integration

---------

Co-authored-by: Manoj K <saimanoj58@gmail.com>
2025-07-24 03:06:24 -07:00

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 });
}
}