Skip to content

Commit 49a26e0

Browse files
authored
Merge pull request #561 from devchat-ai/ide_service_cors
Refactor subproject commit in gui and getCurrentFileInfo endpoint
2 parents 13d2e6f + 4186deb commit 49a26e0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/ide_services/services.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const functionRegistry: any = {
8686
keys: ["code"],
8787
handler: UnofficialEndpoints.runCode,
8888
},
89-
"/getCurrentFileInfo": {
89+
"/current_file_info": {
9090
keys: [],
9191
handler: getCurrentFileInfo,
9292
}
@@ -97,6 +97,12 @@ export async function startRpcServer() {
9797
server = http.createServer((req, res) => {
9898
const parsedUrl = new URL(req.url!, `http://${req.headers.host}`);
9999
logger.channel()?.trace(`request: ${parsedUrl}`);
100+
101+
// 添加 CORS 头
102+
res.setHeader('Access-Control-Allow-Origin', '*'); // 允许所有源,或者指定一个具体的源
103+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); // 允许的 HTTP 方法
104+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type'); // 允许的请求头
105+
100106
if (parsedUrl.pathname === "/favicon.ico") {
101107
res.writeHead(204);
102108
res.end();

0 commit comments

Comments
 (0)