feat: Handle OPTIONS requests for CORS support

- Add handling for OPTIONS requests in RPC server
- Return 200 status with JSON response for OPTIONS
- Update diffApply function keys to include "autoedit"
This commit is contained in:
bobo.yang 2024-07-04 21:45:45 +08:00
parent f9131447c5
commit 6e72521142

View File

@ -59,7 +59,7 @@ const functionRegistry: any = {
handler: () => "vscode",
},
"/diff_apply": {
keys: ["filepath", "content"],
keys: ["filepath", "content", "autoedit"],
handler: UnofficialEndpoints.diffApply,
},
@ -126,6 +126,12 @@ export async function startRpcServer() {
let params: any = {};
if (req.method === 'OPTIONS') {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({"status": "ok"}));
return;
}
if (req.method === "POST") {
let body = "";
req.on("data", (chunk) => {