你好,我这样子写了以后,出现了,Failed to load resource: the server responded with a status of 400 () 是不是还要在本地配置域名,需要怎么配置啊
Access to XMLHttpRequest at 'https://tkmh52fo.engine.lncld.net/1.1/functions/Host' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

我这边没能重现您的问题。如果您是在自己的服务器或者开发机器上跑 Node.js,请您检查 Node.js 初始化部分的 serverURL 是否填写正确(应该填写您的应用绑定的 API 域名)。

附我复现的步骤:

Java 云函数使用的是 lean init 的 Java 模版项目中自带的作为例子的 hello 云函数

Node.js 调用云函数的代码如下:

const AV = require('leancloud-storage');

AV.init({
    appId: "应用的 AppID",
    appKey: "应用的 AppKey",
    serverURL: "https://your-api.domain.com"
});

(async () => {
    try {
        result = await AV.Cloud.run('hello', {})
        console.log(result)
    } catch (error) {
        console.error(error)
    }
})()

has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
应该是跨域的问题,我在本地后端管理系统中调用的java 云函数,使用的是自己的域名

云引擎本身没有限制跨域请求。如果是您的代码里限制了 CORS 的话,需要您进行相应的配置。

另外您说的「本地后端管理系统中调用的java 云函数」,指的是在后端管理系统的前端代码中通过 js 调用还是在后端 node.js 代码中调用?还有也请您确认下 Host 云函数是否存在?