Merge pull request #155 from modelcontextprotocol/jerome/fix/oauth-routing-in-prod-builds

Fix OAuth callback route in production builds
This commit is contained in:
Jerome
2025-02-21 15:08:25 +00:00
committed by GitHub
2 changed files with 8 additions and 5 deletions

View File

@@ -9,7 +9,10 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
const distPath = join(__dirname, "../dist");
const server = http.createServer((request, response) => {
return handler(request, response, { public: distPath });
return handler(request, response, {
public: distPath,
rewrites: [{ source: "/**", destination: "/index.html" }],
});
});
const port = process.env.PORT || 5173;

View File

@@ -86,9 +86,9 @@ export async function handleOAuthCallback(
const response = await fetch(metadata.token_endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
body: JSON.stringify({
body: new URLSearchParams({
grant_type: "authorization_code",
code,
code_verifier: codeVerifier,
@@ -117,9 +117,9 @@ export async function refreshAccessToken(
const response = await fetch(metadata.token_endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
body: JSON.stringify({
body: new URLSearchParams({
grant_type: "refresh_token",
refresh_token: refreshToken,
}),