企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# http-server跨域 ~~~ const http = require('http'); var data = { name:"chengchao" } const server = http.createServer((req,res)=>{ res.writeHead(200,{ 'Content-Type':'application/json', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST' }) res.end(JSON.stringify(data)); }) server.listen(8080) ~~~ # 3-2 koa-跨域 ~~~ const koa = require('koa'); const app = new koa(); app.use(async ctx=>{ ctx.set('Access-Control-Allow-Origin','*') ctx.body = {name:"chengchao"} }) app.listen(8080) ~~~